Uncaught (in promise) Error: Network Error when using a GET request
React app
In general, I have a very strange problem, I wrote the code on a Mac, and everything worked fine, I filled my "site" on the GH page and everything also works fine there. But when I downloaded my project from the repository, launched VSCode, and everything seems to work too, but my local json file with data, the local server does not see it. In the console here is such an error:
Failed to load resource: net::ERR_TOO_MANY_REDIRECTS
Uncaught (in promise) Error: Network Error
at createError (1.chunk.js:890)
at XMLHttpRequest.handleError (1.chunk.js:385)
Here is my request. (I know that for a local jsop file, it is enough to import this method not correct, but I'm interested in the reason why it doesn't work on windows, but it works on MAC.. And everything is OK on the git hub)
componentDidMount() {
Axios.get('./phone.json').then(({data}) => {
this.setState({
phone: data
})
})
}
0
Author: Богдан Чубко, 2020-05-07
1 answers
You need to specify the name of the domain in order to avoid cyclical dependence and subsequent errors.
componentDidMount() {
Axios.get('name/./phone.json').then(({data}) => {
this.setState({
phone: data
})
})
}
0
Author: Богдан Чубко, 2020-05-07 21:15:02