Closed alannaidon closed 2 years ago
The spread operator works in EJS if your runtime supports it. However, the spread operator does not produce strings, so you can't use it to output values. JSON.stringify(object)
will print the JSON for an object, which is one way to see the contents of an object (assuming it's plain data that can be rendered as JSON).
Hi @RyanZim . Thanks for the quick reply!
But should it be throwing Error 500 ?
If I just place the object like
<%= user.metadata %>
I get the [object Object]
but with spread operator it throws error 500 even if the object isn't empty.
<%= ...user.metadata %>
OR <%= ...(user.metadata ?? {}) %>
The spread operator only works inside a Object or Array literal definition, you're using it by itself, that's a syntax error.
I'm wondering if is possible/allowed to use spread operator with EJS. like:
Tried this, but when I check the html, It is shown as
[object Object]
and I can't see the real value.