Skip to content
This repository was archived by the owner on Jul 10, 2019. It is now read-only.

Commit e07ec70

Browse files
committed
feat(@types): add axios interface
1 parent 92cfbf5 commit e07ec70

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

src/@types/vue-types-vue__$axios.d.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,40 @@
1+
import { AxiosInstance, AxiosRequestConfig, AxiosError } from 'axios'
12
import Vue from 'vue'
23

4+
interface NuxtAxiosInstance extends AxiosInstance {
5+
// * Methods
6+
$request<T = any>(config: AxiosRequestConfig): Promise<T>
7+
$get<T = any>(url: string, config?: AxiosRequestConfig): Promise<T>
8+
$delete<T = any>(url: string, config?: AxiosRequestConfig): Promise<T>
9+
$head<T = any>(url: string, config?: AxiosRequestConfig): Promise<T>
10+
$options<T = any>(url: string, config?: AxiosRequestConfig): Promise<T>
11+
$post<T = any>(
12+
url: string,
13+
data?: any,
14+
config?: AxiosRequestConfig
15+
): Promise<T>
16+
$put<T = any>(
17+
url: string,
18+
data?: any,
19+
config?: AxiosRequestConfig
20+
): Promise<T>
21+
$patch<T = any>(
22+
url: string,
23+
data?: any,
24+
config?: AxiosRequestConfig
25+
): Promise<T>
26+
// * Helpers
27+
onRequest(fn: (config: AxiosRequestConfig) => void): void
28+
onResponse<T = any>(fn: (response: T) => void): void
29+
onError(fn: (error: AxiosError) => void): void
30+
onRequestError(fn: (error: AxiosError) => void): void
31+
onResponseError(fn: (error: AxiosError) => void): void
32+
setHeader(name: string, value: any, scopes?: string | string[]): void
33+
setToken(token: string, type: string, scopes?: string | string[]): void
34+
}
35+
336
declare module 'vue/types/vue' {
437
interface Vue {
5-
$axios: any
38+
$axios: NuxtAxiosInstance
639
}
740
}

0 commit comments

Comments
 (0)