You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
zari786
changed the title
How to parse raw result to error response in simple get request
How to parse raw string result to error response in simple get request
Sep 9, 2022
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.
The text was updated successfully, but these errors were encountered: