Last active
June 14, 2021 09:55
-
-
Save mmintel/3379253a042e2f65a92a35f434249ec5 to your computer and use it in GitHub Desktop.
Typescript HttpService Interface
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
export interface HttpService { | |
get<T = any>(url: string, options?: HttpOptions): Promise<T>; | |
post<T = any>(url: string, data?: {}, options?: HttpOptions): Promise<T>; | |
patch<T = any>(url: string, data?: {}, options?: HttpOptions): Promise<T>; | |
put<T = any>(url: string, data?: {}, options?: HttpOptions): Promise<T>; | |
delete<T = any>(url: string, options?: HttpOptions): Promise<T>; | |
} | |
export interface HttpOptions { | |
params?: HttpParams; | |
headers?: HttpHeaders; | |
responseType?: HttpResponseType; | |
} | |
export interface HttpParams { | |
[param: string]: string | string[]; | |
} | |
export interface HttpHeaders { | |
[header: string]: string | string[]; | |
} | |
export type HttpResponseType = 'text' | 'json' | 'arraybuffer' | 'blob'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment