简体   繁体   中英

Check each response from retrofit 2.0

I have responses from server if good token as "users":[{"id":"1234","name":"name"}]

And if bad token as "users":"logout"

How I may check response before convert to objects?

I want do this out onResponse method, it is possibly?

Assuming you're using the default Retrofit Adapter. When declaring your call in your Retrofit interface use Call<ResponseBody> as the response type. When you make the call you'll get a ResponseBody object back from which you can access the JSON by calling body() . You can then decide how to proceed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM