How to use Fuel with a Kotlin coroutine

后端 未结 2 860
失恋的感觉
失恋的感觉 2021-01-13 17:34

Within an Android app, I\'m trying to use Fuel to make an HTTP request within a Kotlin coroutine. My first try is to use the synchronous mode inside a wrapper like this:

2条回答
  •  迷失自我
    2021-01-13 18:13

    From the documentation "to start a coroutine, there must be at least one suspending function, and it is usually a suspending lambda"

    Try this:

    async {
        val token = getToken()
        println(token)
    }
    

提交回复
热议问题