A
A
Anton Myasnov2020-04-16 17:08:52
GitHub
Anton Myasnov, 2020-04-16 17:08:52

Where do you need to put the files so that after deploy they would be found?

Hello. Tell me please.
There is a project in react.
Using fetch, the component receives data.json (as required by the conditions), which lies in the project folder (currently in public)

const getPersonList = async () => {
    const response = await fetch("../data/data.json");
    const data = await response.json();

    sendPerson(data);
  };

I have such a project structure created by create-react-app
5e986683f41e1821205513.jpeg
Locally everything works and finds the data.json file.
But when deploying to github pages, the file is not found and the console throws an error.
In what folder should I put this file so that after assembly it will be fixed?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
McBernar, 2020-04-16
@MambliJoe

In public. Only you need to contact without "..", because public is available directly - site.ru/data/data.json

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question