Today on the developer blog I'm looking at a bug a...
# suitecommerce
s
Today on the developer blog I'm looking at a bug a few of you have asked me about over the years
Uncaught SyntaxError: Unexpected token u in JSON at position 0
https://developers.suitecommerce.com/til-thursday-troubleshooting-uncaught-syntaxerror-unexpected-token-u-in-json-at-position-0
👍🏽 4
👍🏻 1
c
We had a nearly identical error msg when returning JSON from a suitelet. Turned out the suitelet was tacking on some HTML comments behind the JSON data. The fix ending up being
data = data.substring(0, '<!--')
It's a bit of a hack, but it chops off the offending HTML.
🧐 1
Good article too! I ran into the
JSON.parse(JSON.stringify(stuff));
the hard way and scratched me head for a few hours before stumbling on the right answer.
s
The fix ending up being
data = data.substring(0, '<!--')
That is amazing. I'm not seen that one before
I ran into the
JSON.parse(JSON.stringify(stuff));
I loved this when I found out about it. I was writing some hacky stuff to experiment with the application and really wanted to deeply copy a model but our
deepCopy()
utility function is explicitly set up to disallow this