跨域post实例,用到了qs组件来避开ajax信使请求,并兼容Android。
import axios from 'axios';
import qs from 'qs';
axios.post('http://www.xyz.com/request', qs.stringify(params))
.then(response => {
console.log(response);
})
.catch(err => {
console.log(err);
});
本文介绍了一种使用axios和qs组件实现跨域POST请求的方法,该方法能够绕过AJAX预检请求并兼容Android设备。通过示例代码展示了如何将参数序列化并通过POST方式发送到指定服务器。
跨域post实例,用到了qs组件来避开ajax信使请求,并兼容Android。
import axios from 'axios';
import qs from 'qs';
axios.post('http://www.xyz.com/request', qs.stringify(params))
.then(response => {
console.log(response);
})
.catch(err => {
console.log(err);
});