import { AxiosError, AxiosRequestConfig, AxiosResponse, AxiosStatic } from 'axios' import { IAxiosRetryConfig } from 'axios-retry' import Vue from 'vue' import './vuex' interface NuxtAxiosInstance extends AxiosStatic { $request(config: AxiosRequestConfig): Promise $get(url: string, config?: AxiosRequestConfig): Promise $delete(url: string, config?: AxiosRequestConfig): Promise $head(url: string, config?: AxiosRequestConfig): Promise $options(url: string, config?: AxiosRequestConfig): Promise $post(url: string, data?: any, config?: AxiosRequestConfig): Promise $put(url: string, data?: any, config?: AxiosRequestConfig): Promise $patch(url: string, data?: any, config?: AxiosRequestConfig): Promise setBaseURL(baseURL: string): void setHeader(name: string, value?: string | false, scopes?: string | string[]): void setToken(token: string | false, type?: string, scopes?: string | string[]): void onRequest(callback: (config: AxiosRequestConfig) => void | AxiosRequestConfig | Promise): void onResponse(callback: (response: AxiosResponse) => void | AxiosResponse | Promise> ): void onError(callback: (error: AxiosError) => any): void onRequestError(callback: (error: AxiosError) => any): void onResponseError(callback: (error: AxiosError) => any): void create(options?: AxiosRequestConfig): NuxtAxiosInstance } interface AxiosOptions { baseURL?: string, browserBaseURL?: string, credentials?: boolean, debug?: boolean, host?: string, prefix?: string, progress?: boolean, proxyHeaders?: boolean, proxyHeadersIgnore?: string[], proxy?: boolean, port?: string | number, retry?: boolean | IAxiosRetryConfig, https?: boolean, headers?: { common?: Record, delete?: Record, get?: Record, head?: Record, post?: Record, put?: Record, patch?: Record, }, } declare module 'axios' { interface AxiosRequestConfig { progress?: boolean; } } declare module '@nuxt/vue-app' { interface Context { $axios: NuxtAxiosInstance } interface NuxtAppOptions { $axios: NuxtAxiosInstance } } // Nuxt 2.9+ declare module '@nuxt/types' { interface Context { $axios: NuxtAxiosInstance } interface NuxtAppOptions { $axios: NuxtAxiosInstance } interface Configuration { axios?: AxiosOptions } } declare module 'vue/types/vue' { interface Vue { $axios: NuxtAxiosInstance } }