Uncaught SyntaxError: Unexpected token U in JSON at position 0 at JSON.parse () at Response.Body.json

前端 未结 6 2326
情书的邮戳
情书的邮戳 2021-02-15 14:16

I am working on an angular2 project. I am stuck with these errors. The error occured when I tried to send the JSON objects to the backend. It may be due the parsing of JSON obje

6条回答
  •  独厮守ぢ
    2021-02-15 14:36

    Read the call stack closely; the crash is on this line:

            .map(res=> res.json());
    

    The JSON parser is failing to understand the response from the server. See if you can figure out what response the server (the POST to http://localhost:3000/api/users) is sending back. The response supposedly starts with 'U', which cannot be valid JSON.

提交回复
热议问题