Skip to main content

Getting Started

  • Http-pro is lightweight http client built on top of the Fetch API.

Features

  • First-class typescript support.(Better than default typescript support for Fetch API).
  • Simple syntax( For example, hp.get(url) to send a get request).
  • timeout.
  • throwing Error when http status code is not between 200 and 299.( also supports custom error handling logic.)
  • create a Instance with default options.
  • interceptor function.
  • data validation with zod and yup.
  • Node and Bun support.
  • and more...

Installation

npm install http-pro

Requirements

Browser

ChromeFirefoxEdgeOperaSafari
66+ ✔57+ ✔16+ ✔53+ ✔12.1+ ✔

Node

  • Node v 18.0.0 or above.

Bun

  • Bun v 1.0.0 or above.

Simple example

import hp from 'http-pro';

type ResponseData = {
title: string;
completed: boolean;
id: number;
userId: number;
};

const res = await hp.get<ResponseData>(
'https://jsonplaceholder.typicode.com/todos/1'
);
console.log(res.data);
// userId: 1, id: 1, title: "delectus aut autem", completed: false
  • For in depth examples visit get in example section.

live Playground.

  • Playground allows you to try it out http-pro in browser without installing anything.
CodeSandbox

CodeSandbox

StackBlitz

StackBlitz