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

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

    Those who are using create-react-app and trying to fetch local json files.

    As in create-react-app, webpack-dev-server is used to handle the request and for every request it serves the index.html. So you are getting

    SyntaxError: Unexpected token < in JSON at position 0.

    To solve this, you need to eject the app and modify the webpack-dev-server configuration file.

    You can follow the steps from here.

提交回复
热议问题