I have an API that returns a list of replies (limit 5 replies per call) for a message board thread. What I am trying to do, is look for a specific reply uuid in the response. If not found, make another AXIOS GET call for the next 5 replies.
I want to continue this loop until the UUID is called or the AXIOS GET call comes back with no results.
Example API Request:
http://localhost:8080/api/v2/replies?type=thread&key=e96c7431-a001-4cf2-9998-4e177cde0ec3
Example API Reponse:
"status": "success",
"data": [
{
"uuid": "0a6bc471-b12e-45fc-bc4b-323914b99cfa",
"body": "This is a test 16.",
"created_at": "2017-07-16T23:44:21+00:00"
},
{
"uuid": "0a2d2061-0642-47eb-a0f2-ca6ce5e2ea03",
"body": "This is a test 15.",
"created_at": "2017-07-16T23:44:16+00:00"
},
{
"uuid": "32eaa855-18b1-487c-b1e7-52965d59196b",
"body": "This is a test 14.",
"created_at": "2017-07-16T23:44:12+00:00"
},
{
"uuid": "3476bc69-3078-4693-9681-08dcf46ca438",
"body": "This is a test 13.",
"created_at": "2017-07-16T23:43:26+00:00"
},
{
"uuid": "a3175007-4be0-47d3-87d0-ecead1b65e3a",
"body": "This is a test 12.",
"created_at": "2017-07-16T23:43:21+00:00"
}
],
"meta": {
"limit": 5,
"offset": 0,
"next_offset": 5,
"previous_offset": null,
"next_page": "http://localhost:8080/api/v2/replies?_limit=5&_offset=5",
"previous_page": null
}
The loop would call an AXIOS GET on the meta > next_page
url until either the uuid is found in the results or the meta > next_page
is null (meaning no more replies).