“SyntaxError: Unexpected token < in JSON at position 0”

前端 未结 30 1592
花落未央
花落未央 2020-11-22 04:39

In a React app component which handles Facebook-like content feeds, I am running into an error:

Feed.js:94 undefined \"parsererror\" \"SyntaxError: Un

30条回答
  •  再見小時候
    2020-11-22 05:20

    For some, this may help you guys: I had a similar experience with Wordpress REST API. I even used Postman to check if I had the correct routes or endpoint. I later found out that I accidentally put an "echo" inside my script - hooks:

    Debug & check your console

    Cause of the error

    So basically, this means that I printed a value that isn't JSON that is mixed with the script that causes AJAX error - "SyntaxError: Unexpected token r in JSON at position 0"

提交回复
热议问题