Z
Z
zxcursed2021-09-26 20:08:07
React
zxcursed, 2021-09-26 20:08:07

Why is axios not working?

I am making VK mini apps, when I access a php script via axios I get a network error, but if I access a json file, then everything is ok. The piece of code below, when accessing JSON, returns everything fine, if I want to access the .php script, I get a network error.

componentDidMount() {
    axios.get(url)
    .then(res => {
      const data = res.data;
      console.log(res.data)
      this.setState({ data });
     })
  }*/


No, this is not a problem in CORS, because fetch/axios etc. return error exactly inside this class, if you call a separate js script with axios, then everything works, is there someone who can normally explain how I can request a php script on the same server through axios or in some other way inside this code?
class App extends React.Component {
...
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question