Skip to content

Commit aff237c

Browse files
committed
#39 Fix tslint warnings and Vue interface case
1 parent 95a0f63 commit aff237c

File tree

1 file changed

+19
-27
lines changed

1 file changed

+19
-27
lines changed

Diff for: ClientApp/src/plugins/axios.ts

+19-27
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,47 @@
1-
"use strict";
1+
'use strict';
22

3-
import vue from 'vue';
4-
import axios, { AxiosInstance } from "axios";
3+
import Vue from 'vue';
4+
import axios, { AxiosInstance, AxiosRequestConfig } from 'axios';
55

66
// Full config: https://github.com/axios/axios#request-config
77
// axios.defaults.baseURL = process.env.baseURL || process.env.apiUrl || '';
88
// axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
99
// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
1010

11-
let config = {
11+
const config = {
1212
// baseURL: process.env.baseURL || process.env.apiUrl || ""
1313
// timeout: 60 * 1000, // Timeout
1414
// withCredentials: true, // Check cross-site Access-Control
1515
};
1616

17+
// tslint:disable-next-line: variable-name
1718
const _axios = axios.create(config);
1819

1920
_axios.interceptors.request.use(
20-
function(config) {
21-
// Do something before request is sent
22-
return config;
23-
},
24-
function(error) {
25-
// Do something with request error
26-
return Promise.reject(error);
27-
}
21+
// Do something before request is sent
22+
(conf: AxiosRequestConfig) => conf,
23+
// Do something with request error
24+
(error: any) => Promise.reject(error),
2825
);
2926

3027
// Add a response interceptor
3128
_axios.interceptors.response.use(
32-
function(response) {
33-
// Do something with response data
34-
return response;
35-
},
36-
function(error) {
37-
// Do something with response error
38-
return Promise.reject(error);
39-
}
29+
// Do something before request is sent
30+
(response: any) => response,
31+
// Do something with response error
32+
(error: any) => Promise.reject(error),
4033
);
4134

42-
function AxiosPlugin(Vue: typeof vue, options?: any): void {
43-
Vue.prototype.$axios = _axios;
35+
function AxiosPlugin(vue: typeof Vue, options?: any): void {
36+
vue.prototype.$axios = _axios;
4437
}
4538

4639
declare module 'vue/types/vue' {
47-
interface Vue {
48-
$axios: AxiosInstance;
49-
}
40+
interface Vue {
41+
$axios: AxiosInstance;
42+
}
5043
}
5144

52-
vue.use(AxiosPlugin)
53-
45+
Vue.use(AxiosPlugin);
5446

5547
export default Plugin;

0 commit comments

Comments
 (0)