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

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

    For future googlers:

    This message will be generated if the server-side function crashes.

    Or if the server-side function doesn't even exist ( i.e. Typo in function name ).

    So - suppose you are using a GET request... and everything looks perfect and you've triple-checked everything...

    Check that GET string one more time. Mine was:

    '/theRouteIWant&someVar=Some value to send'
    

    should be

    '/theRouteIWant?someVar=Some value to send'
                   ^
    

    CrAsH !       ( ... invisibly, on the server ...)

    Node/Express sends back the incredibly helpful message:
    Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0

提交回复
热议问题