跨域请求携带cookie + axios发送post请求,参数传递不过去


跨域请求携带cookie:

  需要在代码中加上:withCredentials:true,

   参考资料:https://www.jianshu.com/p/552daaf2869c

axios发送post请求,参数传递不过去:

https://www.jianshu.com/p/042632dec9fb

【官网建议】:

https://github.com/axios/axios/blob/master/README.md#using-applicationx-www-form-urlencoded-format

 

axios中文说明:

https://www.kancloud.cn/yunye/axios/234845

var params={
   captcha:this.identiCode,
   first_name:this.firstname,
   last_name:this.lastname,
   userName:this.username,
   passwd:this.psd,
   email:this.email,
   user_type:userType,
}
                  
var qs=require('qs');
axios.post('http://version2.hemasao.com/user/doRegister',qs.stringify(params)).then(function(res){
   //res=qs.parse(res);
   console.log(res);
});
//设置跨域携带cookie
//在main.js里面加入这句话即可(全局默认配置设置方法)
axios.defaults.withCredentials=true

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM