Ombi means "request" in Swahili.
Lightweight HTTP request wrapper built on top of got with normalised responses and managed error handling.
npm install @webinmove/ombiimportRequestfrom'@webinmove/ombi';constrequest=newRequest('https://api.example.com');// GETconstresponse=awaitrequest.call('GET','users/1');// POST with a bodyconstcreated=awaitrequest.call('POST','users',{body: {name: 'Alice'}});// GET with query string paramsconstlist=awaitrequest.call('GET','users',{qs: {page: 1,limit: 20}});// Custom headersconstsecured=awaitrequest.call('GET','protected',{},{Authorization: 'Bearer <token>'});| Parameter | Type | Description |
|---|---|---|
endpoint | string | Base URL for all requests |
| Parameter | Type | Default | Description |
|---|---|---|---|
method | string | none | HTTP method (GET, POST, PUT, ...) |
path | string | none | Path appended to the base endpoint |
params | object | {} | body (sent as JSON for POST/PUT) and/or qs (query string) |
headers | object | {} | Additional request headers |
parentScope | string | '' | Scope label forwarded to ManagedError on HTTP failures |
responseType | string | null | 'json' | got response type; pass null to leave it unset |
Returns a Promise that resolves to:
{ok: boolean,statusCode: number,statusMessage: string,body: unknown,headers: object}HTTP errors (4xx / 5xx) are caught and re-thrown as a ManagedError
(from @webinmove/kosa). All other errors are re-thrown as-is.
ISC