While working on my project, I encountered a delay in response when using the
this.ServiceHandler.getTxnInfo([], params)
API. To handle this, I implemented the use of setTimeout
along with async/await
. Despite these modifications, my promise ended up being rejected.
bookingInfo = [];
timeout(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
This segment showcases the API request being made to retrieve booking information.
async getBookingInfo(dateType: string) {
const params = [];
params.push({code: 'dateType', name: dateType});
params.push({code: 'fromDate', name: '2019-01-01'});
params.push({code: 'toDate', name: '2019-05-31'});
return await this.ServiceHandler.getTxnInfo([], params).toPromise();
}
getBookingDetails() {
this.timeout(150057 ).then(() => this.getBookingInfo('BOOKING').then(
bookings => {
console.log(bookings);
}));
}
Unfortunately, when trying to print out console.log(bookings);
, the promise gets rejected and the get requests fail. I encountered the following error message: https://i.sstatic.net/jQgmz.png
Any insights on how I can resolve this issue would be greatly appreciated.