I have below piece of code in my nodejs. Here I have defined screenshot as const and then redefine it as you can see below. Here the issue is my code was neither throwing any error nor being executed further after the console console.log('opopopopopoopoooooopop'). After sometime I figured out the reason is "I have taken `screenshot variable as const".
const handler = async(request, reply) => {
try {
const screenshotPath = ''
console.log(request.payload, 'ddddddddddddddddddd')
let folderName = `./public/applications/${applicationId}`
let filepath = `${folderName}/${className}.png`
mkdirp(folderName, async(err) => {
await imageUpload(file, className, filepath)
console.log('oooooooooooooooooooo')
if (err) {
return reply({ success: false, message: err.message, data: null })
}
console.log('opopopopopoopoooooopop')
screenshotPath = filepath
console.log(Event)
const screen = await Event.findOne({ })
console.log(screen, 'popopopopopoopopooop')
})
} catch (err) {
console.log({ err })
return reply({ success: false, message: err.message, data: null })
}
}
But the problem is why my code was not throwing the error here. Can someone please help me to get understand this.
Thank you!!!
catchblock?