Today I Learned - Rocky Kev

TIL outputting objects in Node

POSTED ON:

TAGS:

In your Node projects -- sometimes you just need to output the object.

If you console.log(myObject) normally, you'll get something like

{ a: 'a', b: { c: 'c', d: { e: 'e', f: [Object] } } }

If you want it all showing, go with:

console.log(JSON.stringify(myObject, null, 4));

{
"a": "a",
"b": {
"c": "c",
"d": {
"e": "e",
"f": {
"g": "g",
"h": {
"i": "i"
}
}
}
}
}

via How can I get the full object in Node.js's console.log(), rather than '[Object]'?


Related TILs

Tagged:

TIL outputting objects in Node

In your Node projects -- sometimes you just need to output the object. Stringify it.

TIL outputting objects in Node

In your Node projects -- sometimes you just need to output the object. Stringify it.

TIL outputting objects in Node

In your Node projects -- sometimes you just need to output the object. Stringify it.