我目前正在使用以下代码来访问我的路线。我可以访问路线,但它总是告诉我错误401
import axios from 'axios';
export const HTTP = axios.create({
baseURL: `http://localhost/rocourt/01-Backend/api/v1/public/`,
headers: {
Authorization: 'Bearer f4eaa1ff05046c01'
}
});
.vue中的样子
import {HTTP} from '../http-common';
export default {
name: 'adresse',
data() {
return {
posts: [],
errors: [],
message: 'test'
}
},
created() {
HTTP.get(`adresses/1`)
.then(response => {
this.posts = response.data;
})
.catch(e => {
this.errors.push(e)
})
}
}
错误看起来像这样: