// readme

get-it

Generic HTTP request library for Node.js (>= 22.12), browsers, Deno, Bun, and edge runtimes. It is built on fetch().

Features

  • Promise-based API with TypeScript types
  • Automatic JSON serialization/deserialization
  • Base URL and default headers
  • HTTP error throwing (on by default)
  • Timeout with AbortSignal.timeout()
  • Cancellation with the standard AbortController
  • Proxy support in Node.js, Bun, and Deno (reads HTTP_PROXY/HTTPS_PROXY from environment)
  • Middleware system for retry, debug logging, and custom logic
  • Injectable fetch for testing and custom transports
  • Built-in mock fetch with request matching, recording, and vitest matchers

Installation

npm install get-it

Usage

import {createRequester} from 'get-it'

const request = createRequester({
  base: 'https://api.example.com',
  headers: {Authorization: 'Bearer ...'},
})

// Simple GET
const users = await request('/users')
console.log(users.json())

// POST with JSON body (auto-serialized)
const created = await request({
  url: '/users',
  method: 'POST',
  body: {name: 'Espen'},
  as: 'json',
})
console.log(created.body) // parsed JSON

Response

The…