Reaction: Axios network error

I am using axios for the first time and I encountered an error.

  axios.get(
    'http://someurl.com/page1?param1=1&param2=${param2_id}'
  )
  .then(function(response) {
    alert();
  })
  .catch(function(error) {
    console.log(error);
  });

With the correct URL and parameters, when I check the network requests, I really get the correct answer from my server, but when I open the console, I see that it does not call the callback, but instead it encounters an error.

Error: Network error stack trace: createError @ http: // localhost: 3000 / static / js / bundle.js: 2188: 15 handleError @ http: // localhost: 3000 / static / js / bundle.js: 1717: 14

+10
source share
2 answers

If creating an API using NodeJS


Express CORS (Cross-Origin Resource Sharing). :
// This should already be declared in your API file
var app = express();

// ADD THIS
var cors = require('cors');
app.use(cors());

CORS, , Mozilla CORS.

+10

URL, . http:// URL. , URL- 92.920.920.920/api/Token http://92.920.920.920/api/Token. http:// .

0

Source: https://habr.com/ru/post/1684813/


All Articles