Problem in fetch of a json server in react

Viewed 20

VM543:1 Uncaught (in promise) SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON I have problem at fetch of json server that i made alone .The server is correct

1 Answers

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse

The JSON.parse() method parses a JSON string, constructing the JavaScript value or object described by the string. An optional reviver function can be provided to perform a transformation on the resulting object before it is returned.

You are trying to parse json from your response (string). something like JSON.parse('<!doctype html...')

Your server is not returning an application/json data

Related