1
var bodyFormData = new FormData();
      bodyFormData.set("data", "C://Users//harshit.tDownloads\\weather.csv");
      bodyFormData.set("type", "text-intent");
      //axios.post("https://api.einstein.ai/v2/language/datasets/upload", 

      axios({
         method: 'post',
         url: 'https://xxxx/v2/language/datasets/upload',
         data: bodyFormData,
          mode: 'bodyFormData',
         //dataType:'json',
         headers: {
            'Access-Control-Allow-Origin':'*',
            'Access-Control-Allow-Headers':'*',
            'Content-Type': 'multipart/form-data',
            'Authorization': 'Bearer IFMEWWRWLJGTOSBWIJFEIQSCJJFVIVSEG5NEWNSKIRGTOTKQIRKDMUKQGJBFETCFJ5GUENSSIJHUEQJWIFHE4NSWIZHE6TCFGVJUMV2VLFIUKVSPKBMEMNKRGVJFMU2KIRIUUQKMIFIU2R2ZGNJFSTSRIQZEUN2GIVFFC7COIE',
            'Cache-Control': 'no-cache',
            'Access-Control-Allow-Credentials' : true,

            'Access-Control-Allow-Methods':'POST',

            'Accept':'application/json, text/plain, */*'

         }
      })
         .then(function (response) {
            //handle success
            console.log("1111111",response);
         })
         .catch(function (response) {
            //handle error
            console.log(response);
         });

How to Resolve Cross-Origin Read Blocking (CORB) blocked cross-origin response and Cross Origin errors while calling api from axios ,I am getting CORS ERROR please check the above code

htyagi1
  • 23
  • 1
  • 6
  • You can either solve this in the backend using an NPM package called CORS. Or you can use the chrome extension "Allow CORS" for a temporary solution. – Kevin.a Jan 07 '20 at 15:01

1 Answers1

0

If you have control of the nodejs server, you could use the next middleware after installing it with npm install cors

var cors = require('cors');
app.use(cors());

Documentation

fjplaurr
  • 1,818
  • 3
  • 19
  • 36