Assuming I want to transform an error when using promises in NodeJs.
So for instance using request-promise module in code underneath I'm trying to modify the error for a simpler one when making a GET
for a certain URI.
const options = {
'uri': uri,
'headers': { 'Accept-Charset': 'utf-8' }
}
rp.get(options)
.catch(err => {
throw {'statusCode': err.statusCode ? err.statusCode : 503}
})
Is there anyway I can omit the curly brackets like we do when using return
?