Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@qrvey/fetch

Package Overview
Dependencies
Maintainers
0
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@qrvey/fetch - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

25

dist/cjs/index.js

@@ -163,11 +163,30 @@ 'use strict';

}
static async getResponseData(isJsonResponse, response) {
const clonedResponse = response.clone();
let responseData = null;
try {
if (isJsonResponse) {
responseData = await response.json();
} else {
responseData = await response.text();
}
} catch (_) {
responseData = await clonedResponse.text();
}
return responseData;
}
static async handleResponse(response) {
const responseContentType = response.headers.get("content-type");
const isJsonResponse = responseContentType && responseContentType.includes("application/json");
const responseData = await (isJsonResponse ? response.json() : response.text());
if (response.ok) return responseData;
const responseData = await this.getResponseData(
!!isJsonResponse,
response
);
if (response.ok) {
return responseData;
}
throw new RestClientError(response.url, responseData);
}
static fetchData(url, requestOptions) {
return fetch(url, requestOptions).then(this.handleResponse).catch((error) => {
return fetch(url, requestOptions).then(this.handleResponse.bind(this)).catch((error) => {
if (error instanceof RestClientError) throw error;

@@ -174,0 +193,0 @@ throw new RestClientError(url, error);

2

package.json

@@ -5,3 +5,3 @@ {

"main": "dist/cjs/index.js",
"version": "1.1.2",
"version": "1.1.3",
"license": "MIT",

@@ -8,0 +8,0 @@ "publishConfig": {

# @qrvey/fetch
![install size](https://packagephobia.now.sh/badge?p=%40qrvey%2Ffetch)
![coverage](https://img.shields.io/badge/unit_test_coverage-0%25-brightgreen)
![coverage](https://img.shields.io/badge/unit_test_coverage-96%25-brightgreen)

@@ -6,0 +6,0 @@ **@qrvey/fetch** is a lightweight and reliable library for making RESTful requests in Node.js applications. It uses the native `fetch` library (Node.js 18+), avoiding the need for external dependencies.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc