-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapi.ts
42 lines (32 loc) · 894 Bytes
/
api.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { HTTP } from 'http-call';
interface IConfig {
baseURL: string;
}
class AhaAPI {
http: typeof HTTP;
config: IConfig;
constructor(config: IConfig) {
this.http = HTTP;
this.config = config;
}
get(url: string, options: any = {}) {
const fullURL = `${this.config.baseURL}${url}`;
return this.http.get(fullURL, options);
}
put(url: string, options: any = {}) {
const fullURL = `${this.config.baseURL}${url}`;
return this.http.put(fullURL, options);
}
post(url: string, options: any = {}) {
const fullURL = `${this.config.baseURL}${url}`;
return this.http.post(fullURL, options);
}
delete(url: string, options: any = {}) {
const fullURL = `${this.config.baseURL}${url}`;
return this.http.delete(fullURL, options);
}
get defaults(): typeof HTTP.defaults {
return this.http.defaults;
}
}
export default AhaAPI;