Axios Bearer令牌

时间:2019-04-09 12:14:05

标签: axios

我目前正在使用以下代码来访问我的路线。我可以访问路线,但它总是告诉我错误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)
                })
        }
    }

错误看起来像这样:

The errors looks like this

0 个答案:

没有答案