Ombi means "request" in Swahili.
Lightweight HTTP request wrapper built on top of got with normalised responses and managed error handling.
npm install @webinmove/ombiimport Request from '@webinmove/ombi';
const request = new Request('https://api.example.com');
// GET
const response = await request.call('GET', 'users/1');
// POST with a body
const created = await request.call('POST', 'users', {
body: { name: 'Alice' }
});
// GET with query string params
const list = await request.call('GET', 'users', {
qs: { page: 1, limit: 20 }
});
// Custom headers
const secured = await request.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