Search This Blog

Saturday, April 21, 2018

Unexpected token o in JSON at position

Try out on jslint and see if the json is valid, try to fire a JSON.parse(your string) in the chrome developer tool and see if you get the same error.

If you are using nodejs and this is a request from the server.js to fetch data from external system, you might be getting the data in chunks and you will have to use a buffer to accumulate the body.

Once the body is created you can set response headers and send the body back to the angular.

Use Json.stringify to send it back to client and use JSON.parse(incomingstring) to make the json object out of the string.


server.js =======Json.stringified(body) == going as string to client ====JSON.parse(incoming response)==> use the json object in app.

No comments:

Post a Comment