Skip to content

Grabkit

Grab data with METHOD /path. Tuple results. JSON:API by default; plain JSON when you opt out.

Explicit endpoints

Every request is GET /users/1: method and path in one string, relative to an optional base URL.

Tuple results

const [data, error, meta] = await grab(...). Narrow with if (error); failures are returned, not thrown.

JSON:API built in

Denormalised data, relationship merging, and write envelopes. Use format: 'json' for GitHub-style APIs.

Terminal window
pnpm add grabkit
import grabkit from 'grabkit';
const grab = grabkit('https://api.example.com', { casing: 'camelCase' });
const [data, error, meta] = await grab('GET /users/1');
if (error) {
console.error(error.message, error.statusCode);
return;
}
console.log(data.name, meta.statusCode);