{"id":729,"hash":"5ff197b62391612683cd7fc88dda52d17c4ec526116c47df40104554b7cf2939","pattern":"React: Axios Network Error","full_message":"This is my first time using axios and I have encountered an error. \n\n  axios.get(\n    `http://someurl.com/page1?param1=1&param2=${param2_id}`\n  )\n  .then(function(response) {\n    alert();\n  })\n  .catch(function(error) {\n    console.log(error);\n  });\n\nWith the right url and parameters, when I check network requests I indeed get the right answer from my server, but when I open console I see that it didn't call the callback, but instead it caught an error.\n\n  Error: Network Error\n  Stack trace:\n  createError@http://localhost:3000/static/js/bundle.js:2188:15\n  handleError@http://localhost:3000/static/js/bundle.js:1717:14","ecosystem":"npm","package_name":"reactjs","package_version":null,"solution":"If Creating an API Using NodeJS\n\nYour Express app needs to use CORS (Cross-Origin Resource Sharing). Add the following to your server file:\n\n// This should already be declared in your API file\nvar app = express();\n\n// ADD THIS\nvar cors = require('cors');\napp.use(cors());\n\nFor fuller understanding of CORS, please read the Mozilla Documentation on CORS.","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/45980173/react-axios-network-error","votes":97,"created_at":"2026-04-19T04:51:33.562010+00:00","updated_at":"2026-04-19T04:51:33.562010+00:00"}