wynn/ts/src/lib/wynn/wapi.ts
a 4368ec9104
Some checks failed
commit-tag / commit-tag-image (push) Has been cancelled
commit-tag / commit-tag-image (./cmd/caddy) (push) Has been cancelled
noot
2025-03-02 03:23:41 -06:00

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',
}
})
}
}