Home > Blockchain >  JSON.parse() does not work on Linux and Mac
JSON.parse() does not work on Linux and Mac

Time:12-24

I am getting a json response from backend and need to parse the json in frontend. Here is my code:

this.on("success", function(file, response, action) {
                
                response = JSON.parse(response);      
                console.log(response.id);               
                
            });  

When run the code, it said the following.

 Uncaught SyntaxError: Unexpected token < in JSON at position 0
    at JSON.parse (<anonymous>)

Note: The code do works well on Windows and here is the repsonse.

{message: 'Uploaded successfully...', id: 'a690d9b3-4f1e-48a0-83ac-42a2ea7cb904'}

CodePudding user response:

It looks like your response is correct. I think you need to check your form and model in backend. If form is not valid or model include the null=true and so on. I mean you would troubleshoot your response from backend.

  • Related