SyntaxError: Unexpected token u in JSON at position 0
Hey @rodbs
To be honest, return { props: JSON.parse(JSON.stringify(props)) }
seems a little… strange to me. If props
is undefined, your JSON.stringify()
is going to return undefined
and then the parse()
is going to error in exactly the way you posted. I’m not sure why that would behave differently on Netlify or Vercel if you’re using Vercel for static hosting – but if you’re using Vercel for it’s Next.js runtime hosting (which is fundamentally quite different than Netlify) then you may not get that error when it first starts, but you may get that error once you try to hit that page. Not sure.
Anywho, are you up for trying this instead?
return props || {}
That should just return your props directly or if they’re undefined
for one reason or another, an empty object instead of erroring. In you need to return an object with the props
key containing your data, this would be that variant:
return { props: props || {} }
Hope that helps!
–
Jon