Idiomatic HttpClient like axios
npm install @aindu/http-client
/>
An idiomatic and isomorphic HttpClient based on fetch with native support for _TypeScript_.
Only supports modern browsers and NodeJS >= 18
``sh`
npm install @aindu/http-client
This module was thinking like an instantiable HTTP client for that you need to import and create an instance of the client:
`ts
import { HttpClient } from "@aindu/http-client";
const restClient = new HttpClient();
`
This client by default doesn't need any config, but you can set some things in the config to have a better experience.
| { input: null, output: null }
|For instantiating the HttpClient with any config like be:
`ts
import { HttpClient } from "@aindu/http-client";const restClient = new HttpClient({ ... })
`$3
`ts
restClient.get<{ status: "UP" | "DOWN" }>("http://www.api.com/health-check")
`$3
`ts
restClient.post<{ userId: string }>("http://www.api.com/users", { name: "Pepe", surname: "Argento" })`HttpClient API
NOTE: All the methods return Promises.`| method | url | body | options |
|-------------|-----|------|---------|
| get | ✅ | ❌ | ✅ |
| post | ✅ | ✅ | ✅ |
| put | ✅ | ✅ | ✅ |
| delete | ✅ | ❌ | ✅ |
| patch | ✅ | ✅ | ✅ |
| makeRequest | ❌ | ❌ | ✅ |