【发布时间】:2020-04-25 02:32:27
【问题描述】:
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) block cross-origin response and Cross Origin errors while call api from axios ,我收到 CORS ERROR 请检查上面的代码
【问题讨论】:
-
您可以在后端使用名为 CORS 的 NPM 包解决此问题。或者您可以使用 chrome 扩展“允许 CORS”作为临时解决方案。
标签: javascript jquery node.js reactjs axios