In my application, any error is catch and sent via email for review. I'm currently adding headers and body to the email to help reproduce errors. It's currently displayed in a single row. I would like to display this row in a formatted way so it's easier to read the email.
I'm currently using JSON.stringify(myJsonHere, null, 2)
to format my JSON. It does work if I use console.log(JSON.stringify(myJsonHere, null, 2))
to display it, but does not work when I add it to a HTML email like '<b>Headers:</b> ' JSON.stringify(myJsonHere, null, 2)
.
My goal is to get this format:
{
data: "test",
id: 1,
user: {
id: 1,
user: "test"
}
}
Instead of this format:
{data: "test", id: 1, user: {id: 1, user: "test"}}