@mahdiarjangi/phetch-cli
Version:
A CLI directory manager that can be used to create directories, list directory contents and create files
26 lines (20 loc) • 426 B
text/typescript
import type { $Fetch, FetchOptions } from 'ofetch'
class FetchFactory<T> {
private $fetch: $Fetch
constructor($fetcher: $Fetch) {
this.$fetch = $fetcher
}
async call(
method: string,
url: string,
data?: object,
fetchOptions?: FetchOptions<'json'>
): Promise<T> {
return this.$fetch<T>(url, {
method,
body: data,
...fetchOptions
})
}
}
export default FetchFactory