axios请求拦截器错误_Axios请求拦截器在我的Vue应用程序中不起作用

在Vue应用中尝试使用axios请求拦截器时遇到问题,拦截器未在请求前触发。解决方案是将拦截器配置在创建的axios实例上,而不是导入的实例。避免使用window.axios,而应将其绑定到Vue原型或创建独立模块导出axios实例。
摘要由CSDN通过智能技术生成

I'm trying to make axios working with a request interceptor. However

before a request is made the interceptor is not triggered. What could be going wrong here? I've red already a lot about this problem but not

found a solution so far. Could use some help here! This is my code:

import VueRouter from 'vue-router';

import Login from './components/Login.vue'

import Home from './components/Home.vue'

import axios from 'axios';

window.Vue = require('vue');

window.axios = axios.create({

baseURL: 'http://localhost:8080',

timeout: 10000,

params: {} // do not remove this, its added to add params later in the config

});

Vue.use(VueRouter);

// Check the user's auth status when the app starts

// auth.checkAuth()<

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值