Categories
JavaScript Answers

How to fix Axios Network Error with React?

Spread the love

Sometimes, we want to fix Axios Network Error with React.

In this article, we’ll look at how to fix Axios Network Error with React.

How to fix Axios Network Error with React?

To fix Axios Network Error with React, we enable CORS in our back end.

For instance, we write

const app = express();
const cors = require("cors");

app.use(cors());

to add the cors middleware in our Express app.

Then we won’t get CORS error when we make requests to it.

We install cors by running

npm i cors

Conclusion

To fix Axios Network Error with React, we enable CORS in our back end.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *