Invalid json response with getServerSideProps? #12549
Unanswered
taylor-lindores-reeves
asked this question in
Help
Replies: 1 comment 1 reply
-
The error you're seeing is telling to that it's trying to parse HTML as JSON. So somehow the client is getting an HTML response. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey, I just set up GetServerSideProps now in my index page (Home). Above my stateless component, I have the following simply example straight from the website docs:
In my backend which is in /db/router.js I am using a MongoDB mongoose set-up. Here is the api route:
I amn simply trying to return an API Key from the server to keep it serverside. All I am getting in response though is a html doc, thus, the following error:
FetchError: invalid json response body at http://localhost:3000/api/contact reason: Unexpected token < in JSON at position 0
Any idea what's going on when I simply want to respond with some json??
Beta Was this translation helpful? Give feedback.
All reactions