DEV Community

Paul C. Ishaili
Paul C. Ishaili

Posted on

2 1

Unexpected token < in json at position 0 fetch api

This error occurred when trying to fetch a local json file:


How I fixed this.

solution to Unexpected token < in json at position 0 fetch apimrpaulishaili

Put the json data file (or folder containing the json data files) in the public directory of your react project and try to fecth again.


Further Reading

https://stackoverflow.com/questions/37269808/react-js-uncaught-in-promise-syntaxerror-unexpected-token-in-json-at-posit

https://docs.microsoft.com/answers/questions/449617/syntaxerror-unexpected-token-lt-in-json-at-positio.html

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay