Skip to content

Getting Started with @briklab/reqor ​

reqor wraps fetch and exposes a fluent API with built-in retries, timeouts, and middleware.

Basic GET request ​

ts
import reqor from "@briklab/reqor";

const response = await reqor("https://httpbin.org/json").get();
console.log(response.status);          // 200
console.log(await response.json());    // parsed body

You can chain configuration methods before calling get() or post():

ts
const r = reqor("https://httpbin.org/get")
            .retry(3)          // retry up to 3 times on failure
            .timeout(2000)     // per‐attempt timeout in ms
            .get();

POST request ​

ts
const resp = await reqor("https://httpbin.org/post")
                .data({ hello: "world" })  // body for POST
                .post();
console.log(await resp.json());

Retries by default ​

reqor(url).retry(5).get() is equivalent to passing options:

ts
reqor(url).get({ retry: { number: 5 } });

Fluent options ​

MethodPurpose
.retry(n)set retry count
.timeout(ms)per‑attempt timeout
.totalTimeout(ms)overall timeout for all retries
.params(obj)add query parameters
.data(v)request body for post
.headers(h)headers for post
.after(ms)delay before executing

Each method returns the same instance so you can chain them and then call get()/post().

Quick note about middleware ​

You can attach global or local middleware to inspect/modify the request/response. See the examples page.

Live Demo ​

Recommended to test it in your browser. The test here might not work properly
Console
No logs yet.

What's next ​