I\'m running into an issue when trying to pass error messages around using web sockets. I can replicate the issue I am facing using J
As no one is talking about the why part, I'm gonna answer it.
Why this JSON.stringify
returns an empty object?
> JSON.stringify(error);
'{}'
Answer
From the document of JSON.stringify(),
For all the other Object instances (including Map, Set, WeakMap and WeakSet), only their enumerable properties will be serialized.
and Error
object doesn't have its enumerable properties, that's why it prints an empty object.