Skip to content

Commit 44d858c

Browse files
committed
feat: add config fetch api
1 parent c176343 commit 44d858c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/config/fetchAPI.ts

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* eslint-disable no-unused-vars */
2+
import axios, { AxiosInstance } from 'axios'
3+
4+
class fetchAPI {
5+
private axiosDefault: AxiosInstance
6+
7+
private baseUri: string
8+
9+
constructor(baseUri: string) {
10+
// @ts-ignore
11+
this.axiosDefault = null
12+
this.baseUri = baseUri
13+
}
14+
15+
get default(): AxiosInstance {
16+
if (!this.axiosDefault) {
17+
this.axiosDefault = axios.create({
18+
baseURL: this.baseUri,
19+
})
20+
return this.axiosDefault
21+
}
22+
23+
return this.axiosDefault
24+
}
25+
}
26+
27+
export default fetchAPI

0 commit comments

Comments
 (0)