axios post請求轉formdata


axios post請求轉formdata

axios({ url: Config.url.wechat_url + '/member/register', method: 'post', data: { password: self.password, code: self.validCode, phone: self.phoneNumber }, transformRequest: [function (data) { var ret = ''; for (var it in data) { ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&' } return ret }], headers: {'Content-Type': 'application/x-www-form-urlencoded'} }).then(function (res) { if (res.data.code === 200) { self.$toast ({message:'恭喜您注冊成功', duration: 1500}); localStorage.setItem("phoneNumber", res.data.data.phoneNumber); localStorage.setItem("password", res.data.data.password); setTimeout(function () { window.location.href = '/user/login'; },1500) }else{ self.$toast ({message:'哎呀,請求出錯啦', duration: 1500}) } }).catch(function (error) {self.$toast ({message:'網絡出了問題', duration: 1500});})

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM