New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

web-fetch-client

Package Overview
Dependencies
Maintainers
0
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

web-fetch-client

Simple REST client for web `fetch` module. Adds retries and timeout support to `fetch` module.

latest
Source
npmnpm
Version
0.2.5
Version published
Maintainers
0
Created
Source

web-fetch-client

npm version

Simple REST client for web fetch module.

Has a single default export request.

Adds retries and timeout support to fetch module.

Adds default JSON support to the body and response.

Query parameters parsed from body.

Status code >= 400 will cause a rejection of the call.

No dependencies.

Example:

import request from 'web-fetch-client';

const body = {};
const headers = {};
const options = {};

const response = await request('POST', '/v1/endpoint', 'https://my-host.com', body, headers, options);

TypeScript Example:

import request, { Options, Headers, Response } from 'web-fetch-client';

interface ApiResponse {
  foo: string;
}

const options: Options = { retry: 1 };

const response = await request<ApiResponse>('GET', '/foo', 'https://api.example.com', {}, {}, options);

console.log(response.foo, response.statusCode);

Options:

retry: number of retries, default 0
response: response timeout in ms, default 10000
deadline: deadline timeout in ms, default 60000
verbose: should log warnings, default true

All options are optional.

Building / Publishing

  • Make changes
  • Update version in package.json
  • Run npm build
  • Run npm publish

Keywords

fetch

FAQs

Package last updated on 25 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts