Is it not possible to stringify an Error using JSON.stringify?

后端 未结 11 2403
心在旅途
心在旅途 2020-11-22 07:54

Reproducing the problem

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

11条回答
  •  甜味超标
    2020-11-22 08:22

    JSON.stringify(err, Object.getOwnPropertyNames(err))
    

    seems to work

    [from a comment by /u/ub3rgeek on /r/javascript] and felixfbecker's comment below

提交回复
热议问题