Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 9 additions & 34 deletions packages/tests/axios.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,10 @@
import axios2 from "axios"
export const axios = {
async post<T = any, R = axios2.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios2.AxiosRequestConfig<D>): Promise<any> {
try {
const res = await axios2.post(url, data, config)
return res
} catch(e: any) {
return e.response
}
},
get: async (...args: any) => {
try {
const res = await axios2.get(...args)
return res
} catch(e) {
return e.response
}
},
put: async (...args: any) => {
try {
const res = await axios2.put(...args)
return res
} catch(e) {
return e.response
}
},
delete: async (...args: any) => {
try {
const res = await axios2.delete(...args)
return res
} catch(e) {
return e.response
}
},
}

const client = axios2.create();

client.interceptors.response.use(
(response) => response,
(error) => error.response
);

export const axios = client;