SyntaxError: Unexpected end of JSON input","

Hi! My netlify functions are deployed and were working before. But now they are returning error 502 SyntaxError: Unexpected end of JSON input"," whenever I call POST method. It does save the data in Supabase database but doesnt return the JSON object.

Kindly guide me why it causing this issue?.

Hi @aff_cue :wave:t6: ,

Welcome to the forums and thank you so much for reaching out. Did you search the forums and see if any of the other solutions helped? Have you looked through this resource? It is a compilation of all of our build and deploy resources. This is a good starting point.

If you have worked through those guides and are still encountering issues please share the following information:

  • the name of your build instance: “
  • what you have already tried
  • any error messages you have received in your terminal window or in the developer console

@aff_cue The error is as you’ve pasted in:

SyntaxError: Unexpected end of JSON input

Look in your code for somewhere you are trying to parse a json string into an object.
Ensure that the string is actually a valid json structure.

1 Like

@nathanmartin Im not doing JSON.parse. The response is coming like this
Object {
“data”: null,
“errors”: Array [
Object {
“extensions”: Object {
“exception”: Object {
“clientVersion”: “2.30.3”,
“locations”: Array [
Object {
“column”: 3,
“line”: 3,
“message”: “Unexpected end of JSON input”,
“path”: Array [

when I hit https://{myAppDomain}/.netlify/functions/{functionName}

It does save the values that I sent to body. But returns this above response.

The error indicates that something is trying to consume some JSON, and is unable to do so because it is malformed.

While it may not be “you” directly, if it’s a function that you’ve deployed, then it’s still likely to be within your code, even if it were a function that was automatically deployed by a system that you’d just chosen to work with.

So if it’s what you see as the response given by a function that you’ve created yourself, you should debug the code of that particular function.