gui/modules/desktop/electron/libs/v1-client.ts
Neil b43a64566d
implement push notification using pushy (#299)
* #245 implement push notification using pushy

* #298 subscribe to installed package

---------

Co-authored-by: neil <neil@neils-MacBook-Pro.local>
2023-03-15 11:53:37 +08:00

31 lines
636 B
TypeScript

import axios from "axios";
import path from "path";
const base = "https://api.tea.xyz";
export async function get<T>(urlPath: string) {
const url = new URL(path.join("v1", urlPath), base).toString();
// TODO: add headers
const req = await axios.request<T>({
method: "GET",
url,
headers: {}
});
return req.data;
}
export async function post<T>(urlPath: string, data: { [key: string]: any }) {
const url = new URL(path.join("v1", urlPath), base).toString();
const req = await axios.request<T>({
method: "POST",
url,
headers: {},
data
});
console.log("REQ:", req.data);
return req.data;
}
export default get;