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

前端 未结 30 1597
花落未央
花落未央 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:21

    I had the same error message following a tutorial. Our issue seems to be 'url: this.props.url' in the ajax call. In React.DOM when you are creating your element, mine looks like this.

    ReactDOM.render(
        ,
        document.getElementById('content')
    );
    

    Well, this CommentBox does not have a url in its props, just data. When I switched url: this.props.url -> url: this.props.data, it made the right call to the server and I got back the expected data.

    I hope it helps.

提交回复
热议问题