I want to call another web-api from my backend on a specific request of user.
How can I achieve this in Ktor. Like in spring boot we use Rest Template, but how can I do the same in Ktor.
Reference Article for doing the same in spring boot: (Call another rest api from my server in Spring-Boot)
CodePudding user response:
You can use ktor http client
val client = HttpClient(CIO)
val response: HttpResponse = client.get("https://ktor.io/")
println(response.status)
client.close()
https://ktor.io/docs/request.html
CodePudding user response:
Use an HTTP client like Unirest to make the call to the other web api
Unirest.get("https://reqres.in/api/users/1").asString();