My Node.js application reads a string, containing JSON data, from a Python backend using GET method. Sometimes when I use JSON.parse() and refresh the page after it succeeds, it gives an Unexpected token , error.
[
{
"postid":"c4jgud85mhs658sg4hn94jmd75s67w8r",
"email":"[email protected]",
"post":"hello world",
"comment":[]
},
{
"postid":"c4jgud85mhs658sg4hn94jmd75s67w8r",
"email":"[email protected]",
"post":"hello world",
"comment":[]
}
]
By console.logging the JSON object, I was able to verify that it only prints the object partially (meaning that only a part of the object was passed) when it gives the error - for example:
4hn94jmd75s67w8r",
"email":"[email protected]",
"post":"hello world",
"comment":[]
}
]
or
[
{
"postid":"c4jgud85mhs658sg
In node.js, Im only using
var data = JSON.parse(resJSON); //resJSON is the variable containing the JSON
commentin the first object.GETrequest?