Https get promise endpoint sample

A promise is a JavaScript object that represents the eventual result of an asynchronous process. After the promise object is created, it serves as a placeholder for the future success or failure of the asynchronous process. While the promise object is waiting, the remaining segments of the script can execute. With promises, developers can write asynchronous code that is intuitive and efficient.
var headerObj = { name: 'Accept-Language', value: 'en-us' };
https.get.promise({
 url: 'https://www.testwebsite.com', 
 headers: headerObj 
}).then(function(response){ 
log.debug({ title: 'Response', details: response });
}).catch(function onRejected(reason) { 
log.debug({ title: 'Invalid Get Request: ', details: reason }); 
})

Leave a comment

Your email address will not be published. Required fields are marked *