let axios = require('axios')
let getShipmentDetails = async (url) => {
var res = await axios({
method: 'post',
url: url,
headers: { Authorization: "<Bearer token>"},
data: {
"filter" : {
"type" : "postDispatch",
"states" : ["Delivered"],
"orderDate" : {
"from" : "2022-03-02",
"to" : "2022-03-10"
}
}
}
})
if (res['data']['hasMore'] == true) {
var newurl = "https://api.flipkart.net/sellers"+res['data']['nextPageUrl'];
console.log(newurl)
let more = await getShipmentDetails(newurl)
return res['data']['shipments'].concat(more);
}
else {
console.log(res['data'])
return res['data']['shipments']
}
}
getShipmentDetails("https://api.flipkart.net/sellers/v3/shipments/filter/")
.then(result => {})
The newUrl is same everytime. I cannot able to access content of next page in results.
res[‘data’][‘nextPageUrl’] =
/v3/shipments/filter?next_token=ewogICJmaWx0ZXJUeXBlIiA6ICJwb3N0RGlzcG……GF0ZSIgOiAib2FwaV9wb3N0X2Rpc3BhdGNoIgp9