[Http] Add `Http` module
kiaking opened this issue · 0 comments
kiaking commented
Http
is a wrapper around axios
that provides some additional features. For response type, I guess we can use AxiosResponse as is if we don't have any other thoughts. Here I'm defining as Response
just to make the api look simpler.
Import
import { Http } from '@globalbrain/sefirot/http/Http'
Api
class Http {
get<T = any, R = Response<T>>(
url: string,
config?: Config
): Promise<R>
post<T = any, R = Response<T>>(
url: string,
data?: Record<string, any>,
config?: Config
): Promise<R>
put<T = any, R = Response<T>>(
url: string,
data?: Record<string, any>,
config?: Config
): Promise<R>
delete<T = any, R = Response<T>>(
url: string,
config?: Config
): Promise<R>
resolve<T = any, R = Response<T>>(
method: Method,
url: string,
config?: Config
): Promise<R>
// Send multi-part request to upload files.
upload<T = any, R = Response<T>>(
url: string,
data?: Record<string, any>
): Promise<R>
// Download a file.
download(
url: string,
config?:Config
): Promise<void>
}