I'm working on hotel booking and I want to show autocomplete cities to the user but I'm stuck on error response when the response is successful it's working fine, but when no data found it throws error and the app crash.
here is a blow code
val apiResponse = amadeus.get("https://test.api.amadeus.com/v1/reference-data/locations/cities?keyword=$keyword")
val type = Types.newParameterizedType(
List::class.java,
Location::class.java
)
val responseType = Types.newParameterizedTypeWithOwner(
ApiResult::class.java,
ApiResult.Success::class.java,
type
)
val locationAdapter =
amadeus.moshi.adapter<ApiResult.Success<List<Location>>>(resultType)
val cityDetail = locationAdapter.fromJson(apiResponse)
I'm getting error on this line val cityDetail = locationAdapter.fromJson(apiResponse) when user enter invalid location which does not found.
I've attached the error along with raw response.
Any help will be appreciated.
I'm working on hotel booking and I want to show autocomplete cities to the user but I'm stuck on error response when the response is successful it's working fine, but when no data found it throws error and the app crash.
here is a blow code
I'm getting error on this line val cityDetail = locationAdapter.fromJson(apiResponse) when user enter invalid location which does not found. I've attached the error along with raw response. Any help will be appreciated.