I have been using Volley to make requests to my api. Everything has been going great so far. I deserialize the JSON response and cache the object into my db, then query my db to show the object's data. But, what if my response is something like this:
{
"Author": {
"name": "John Doe",
"Books": [
{
"url": "www.myapi.com/book/1"
},
{
"url": "www.myapi.com/book/2"
},
{
"url": "www.myapi.com/book/3"
}
],
"Articles": [
{
"url": "www.myapi.com/article/1"
}
]
}
}
The urls are the api endpoints to the actual objects. To get all of the information that I need for my views, I will have to do a for loop and make 4 more api requests to get by Books and Articles objects. I am not sure what the best way is to accomplish this. I can't query my database until the requests have completed, and there isn't a way to know when the last request has finished.
This seems common, but I haven't come across anything yet that deals with this type of situation. How can this be done?
0 comments:
Post a Comment