Created
April 23, 2022 19:57
-
-
Save hiteshchopra11/3a4c8310888b8a638bd05df527ef4a61 to your computer and use it in GitHub Desktop.
API call
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lifecycleScope.launchWhenCreated { | |
withContext(Dispatchers.IO) { | |
client.newCall(request).enqueue(responseCallback = object : Callback { | |
override fun onFailure(call: Call, e: IOException) { | |
Log.e(MainActivity.TAG, "API Call Failure ${e.localizedMessage}") | |
} | |
override fun onResponse(call: Call, response: Response) { | |
Log.d(MainActivity.TAG, "APi Call Success ${response.body.toString()}") | |
} | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment