Last active
November 11, 2020 09:25
-
-
Save oleh-zaporozhets/1b5ef896a7bb06d50db915a585a199b4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MainApi extends HttpClient { | |
| private static classInstance?: MainApi; | |
| private constructor() { | |
| super('https://api.awesome-site.com'); | |
| } | |
| public static getInstance() { | |
| if (!this.classInstance) { | |
| this.classInstance = new MainApi(); | |
| } | |
| return this.classInstance; | |
| } | |
| public getUsers = () => this.instance.get<User[]>('/users'); | |
| public getUser = (id: string) => this.instance.get<User>(`/users/${id}`); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment