Trying to fix NPE around these lines.

This commit is contained in:
Vitor Pamplona
2023-02-04 10:41:01 -05:00
parent bbfd060328
commit 2992d9daf0
@@ -43,9 +43,13 @@ object ImageUploader {
client.newCall(request).enqueue(object : Callback { client.newCall(request).enqueue(object : Callback {
override fun onResponse(call: Call, response: Response) { override fun onResponse(call: Call, response: Response) {
response.use { response.use {
val tree = jacksonObjectMapper().readTree(response.body!!.string()) val body = response.body
val url = tree.get("data").get("link").asText() if (body != null) {
onSuccess(url) val tree = jacksonObjectMapper().readTree(body.string())
val url = tree?.get("data")?.get("link")?.asText()
if (url != null)
onSuccess(url)
}
} }
} }