This is a handy tool to print the node request
library API response on console so that we can print it for debugging
and also sending infomation to the API teams. I always try to print it out from the application to triage the issue with API teams.
function printResponse(response) {
console.log(`Request:`);
console.log(`${response.request.method} ${response.request.href}`)
console.log(`Headers: ${JSON.stringify(response.request.headers)}`)
console.log(`Response:`);
console.log(`Headers: ${JSON.stringify(response.headers)}`)
console.log(`Status Code: ${response.statusCode}`)
console.log(JSON.stringify(response.body))
}
In the future this can turn into an npm project. Wait and see.