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

@ultraq/fetch-utils

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ultraq/fetch-utils

A collection of utilities for working with the Fetch API

latest
Source
npmnpm
Version
2.0.3
Version published
Maintainers
0
Created
Source

fetch-utils

Build Status codecov npm Bundlephobia minified size

A collection of utilities for working with the Fetch API.

Installation

npm install @ultraq/fetch-utils

API

checkStatus(reponse)

Make sure the response from the server is an OK one, throwing an error if it isn't. Usually chained right after the fetch request, eg:

fetch(/* ... */)
  .then(checkStatus)
  .then(response => {
  	// ...
  });

responseAsJson(response)

Assumes a JSON response and attempts to parse and return it as a JavaScript object. Usually chained right after the response is deemed OK, eg:

fetch(/* ... */)
  .then(checkStatus)
  .then(responseAsJson)
  .then(object => {
  	// ...
  });

responseAsText(response)

Process the response body as a string. Usually chained right after the response is deemed OK, eg:

fetch(/* ... */)
  .then(checkStatus)
  .then(responseAsText)
  .then(string => {
  	// ...
  });

Keywords

fetch

FAQs

Package last updated on 24 Dec 2024

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