Vuetable-2: Axios response interceptor not working

Created on 8 Jan 2018  路  1Comment  路  Source: ratiw/vuetable-2

axios.interceptors.response.use(
  function(response) {
    return Promise.resolve(response)
  },
  function(error) {
    console.log(error.response)
    return Promise.reject(error)
  }
)

this is not work. for example, i have other axios request and this code works perfect, but not with vue-table2.
look at this screenshot
screenshot from 2018-01-08 14-06-54

First error is vue-table2 request. when it unauthorized (error), the axios interceptors not working. But take a look the second error. The second error is my other axios request, it unauthorized too, but interceptors is working.

how to fix this? help me mr. @ratiw

Most helpful comment

It's working now using http-fetch

<vuetable ref="vuetable" :api-url="vuetable.apiUrl" 
:fields="vuetable.fields" :append-params="filter" pagination-path="" 
:per-page="perPage" @vuetable:pagination-data="onPaginationData" 
:css="vuetable.css.table" :http-fetch="myFetch">

add :http-fetch="myFetch" to vuetable component

then create method

myFetch(apiUrl, httpOptions) {
      return axios.get(apiUrl, httpOptions)
    },

>All comments

It's working now using http-fetch

<vuetable ref="vuetable" :api-url="vuetable.apiUrl" 
:fields="vuetable.fields" :append-params="filter" pagination-path="" 
:per-page="perPage" @vuetable:pagination-data="onPaginationData" 
:css="vuetable.css.table" :http-fetch="myFetch">

add :http-fetch="myFetch" to vuetable component

then create method

myFetch(apiUrl, httpOptions) {
      return axios.get(apiUrl, httpOptions)
    },
Was this page helpful?
0 / 5 - 0 ratings

Related issues

arthurvasconcelos picture arthurvasconcelos  路  3Comments

ericksongmr picture ericksongmr  路  5Comments

wa05 picture wa05  路  3Comments

PrimozRome picture PrimozRome  路  5Comments

larryu picture larryu  路  6Comments