Skip to content

Instantly share code, notes, and snippets.

@hiteshchopra11
Created April 23, 2022 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hiteshchopra11/3a4c8310888b8a638bd05df527ef4a61 to your computer and use it in GitHub Desktop.
Save hiteshchopra11/3a4c8310888b8a638bd05df527ef4a61 to your computer and use it in GitHub Desktop.
API call
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