I'm making an application and wanted to give a request that the API bring an image of that site in response. For example, giving the 404 error would like you to bring this .
How can I do this?
I currently have a method like this:
app.use((req, res, next) => {
const error = new Error('Não há nada aqui :c');
error.status = 404;
next(error);
});
app.use((error, req, res, next) => {
res.status(error.status || 500);
res.json({
error: {
mensagem: error.message
}
})
});