When using a try/catch for an async/await request, and a some logic needs to be performed on the result, where is the best place to do that logic? I have a function like this
function synchronousTransform (data) {
// some code to reformat `data` that is not working
}
async function requestFn () {
try {
const myPromisedValue = await axios.get(url)
const result = synchronousTransform(myPromisedValue.data)
res.status(200).send(result)
} catch (xhrError) {
res.status(500).send(xhrError)
} finally {
console.log('done')
}
}
It seems that something in synchronousTransform isn't working and I'm getting errors. However, the only thing I'm seeing thrown in the try/catch block is like it's a problem with the XHR. How can I isolate the functionality of synchronousTransform so that I can see the actual exceptions it's causing?
Aucun commentaire:
Enregistrer un commentaire