在axios上的跨域 [英] cross domain at axios
本文介绍了在axios上的跨域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在为axios更改jquery ajax,但没有跨域使用axios:
I am changing jquery ajax for axios and I not getting use axios with cross domain:
axios.get(myurl, {
headers: { 'crossDomain': true },
}).then(res => {
console.log(res);
}).catch(error => {
console.log('erro', error);
})
我的jquery代码正在运行:
My jquery code is working:
$.ajax({
type: 'GET',
crossDomain: true,
url:myurl,
success: (res) => {},
error: (fail) => {}
})
错误:飞行前响应中Access-Control-Allow-Headers不允许请求标头字段crossDomain.
The error: Request header field crossDomain is not allowed by Access-Control-Allow-Headers in preflight response.
有人可以帮助我吗?
推荐答案
"crossDomain"不必在标题中
"crossDomain" does not have to be in headers
axios.get(myurl, {
crossDomain: true
}).then(res => {
console.log(res);
}).catch(error => {
console.log('error', error);
})
致谢
这篇关于在axios上的跨域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文