跨域請求攜帶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