Api.ts 340 Bytes
Newer Older
silver47gin's avatar
silver47gin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
class Api {
  baseUrl: string;

  api: Api;

  constructor(baseUrl: string) {
    this.baseUrl = baseUrl;
  }

  getUrl = (path: string) => `${this.baseUrl}${path}`;

  getUserInfo = async (code: string) =>
    await (await fetch(this.getUrl(`/getUserInfo?code=${code}`))).json();
}

export const api = new Api("http://10.1.121.166:8000");