Here I am spreading the err
object (which is an Error
object in Node.js) and cloning it as error
, but some properties of the err
object are not copied to error
.
const error = { ...err };
console.log(error.name, error.status, err.name, err.status);
The output is:
undefined 400 SyntaxError 400
Why is error.name
undefined
?