const axios = require('axios');
const getShipmentDetails = ((nextCall) => {
        const res = axios({
            method: 'post',
            url: nextCall,
            headers:{ Authorization: "<Generated Bearer Token>"},
            data:{
                "filter" : {
                    "type" : "postDispatch",
                    "states" : ["SHIPPED"],
                    "orderDate" : {
                        "from" : "2022-04-01",
                        "to" : "2022-04-04"
                    }
                }
            }
        })
        if(res['data']['hasMore'] == false ){
            return res['data']['shipments'].concat(getShipmentDetails(res['data']['nextPageUrl']))
        }
        else{return res['data']['shipments']}
});
const result = getShipmentDetails("https://api.flipkart.net/sellers/v3/shipments/filter/");
console.log(result);
I am Recursively fetching data from paginated API. I am getting multiple errors while adding await/async functions in this code. Due to delay from the API calls output is printing "Undefined". Please update this code with await/async or any suitable method so that data from all the pages is concatenated.
 
     
     
    