被VUE和axios折磨的岁月,碰到404和401错误
axios如何发送Basic Auth认证数据??
这几天都在搞vue和flask前后端分离的小东西
后端采用了HTTPBasicAuth加令牌认证
然后写好后端接口,就用前端axios发送请求
//前端
//api.js
let base = 'http://127.0.0.1:5000/api';
export const requestLogin = params => {
return axios.post(`${base}/login`, params).then(res => res.data);
};
//Login.vue
methods: {
handleSubmit2(ev) {
var _this = this;
this.$refs.ruleForm2.validate((valid) => {
if (valid) {
this.logining = true;
//NProgress.start();
var loginParams = { name: this.ruleForm2.account, password: this.ruleForm2.checkPass };
requestLogin(loginParams).then(data => {
.....
});
} else {
cons