31 lines
572 B
TypeScript
31 lines
572 B
TypeScript
import { config } from "#/config";
|
|
import { injectable } from "@needle-di/core";
|
|
import axios, { AxiosInstance } from "axios";
|
|
import { setupCache } from 'axios-cache-interceptor';
|
|
|
|
|
|
@injectable()
|
|
export class WApi {
|
|
c: AxiosInstance
|
|
|
|
constructor() {
|
|
const c = axios.create({
|
|
baseURL: config.WAPI_URL,
|
|
})
|
|
setupCache(c);
|
|
this.c = c;
|
|
}
|
|
|
|
async get(path:string, params?: any) {
|
|
return this.c.get(path, {
|
|
params,
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'Content-Type': 'application/json',
|
|
}
|
|
})
|
|
}
|
|
|
|
|
|
}
|