I already asked this question here, but did not receive an answer to it, this time I transferred everything to the sandbox, so that it is easier to understand the essence of the problem
How to get local JSON (fetch)? I do a service, then I call the class instance This is not how it works:
import React from "react";
import "./styles.css";
export default function App() {
const onFetch = async () => {
const req = await fetch("./data.json");
return req.json();
};
const onMap = () => {
onFetch().then(data => console.log(data));
};
return <div className="App">{onMap()}</div>;
}
Unexpected token < in JSON at position 0 https://codesandbox.io/s/silly-montalcini-2z146