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

fetch-request-browser

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-request-browser - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

2

dist/index.js

@@ -1,1 +0,1 @@

import{buildOptions,buildRequest,extractResponseData,delay}from"./utils/utils.js";import{validateResponse}from"./validations/validations.js";const __executeSend=async(e,t)=>{const s=buildOptions(t),n=buildRequest(e,s.requestOptions),d=await fetch(n);return validateResponse(n,d,s),d.redirected&&console.warn(`The request sent to '${n.url}' was redirected. Please update the implementation to avoid future redirections.`),{code:d.status,headers:d.headers,data:await extractResponseData(d,s.responseDataType)}},send=async(e,t,s)=>{try{return await __executeSend(e,t)}catch(n){if(!Array.isArray(s)||0===s.length)throw n;return await delay(s[0]),send(e,t,s.slice(1))}},sendGET=async(e,t,s)=>send(e,{...t,requestOptions:{...t?.requestOptions,method:"GET"}},s),sendPOST=(e,t,s)=>send(e,{...t,requestOptions:{...t?.requestOptions,method:"POST"}},s),sendPUT=(e,t,s)=>send(e,{...t,requestOptions:{...t?.requestOptions,method:"PUT"}},s),sendPATCH=(e,t,s)=>send(e,{...t,requestOptions:{...t?.requestOptions,method:"PATCH"}},s),sendDELETE=(e,t,s)=>send(e,{...t,requestOptions:{...t?.requestOptions,method:"DELETE"}},s);export{send,sendGET,sendPOST,sendPUT,sendPATCH,sendDELETE};
import{extractMessage}from"error-message-utils";import{buildOptions,buildRequest,extractResponseData,delay}from"./utils/utils.js";import{validateResponse}from"./validations/validations.js";const __executeSend=async(e,s)=>{const t=buildOptions(s),n=buildRequest(e,t.requestOptions),r=await fetch(n);return validateResponse(n,r,t),r.redirected&&console.warn(`The request sent to '${n.url}' was redirected. Please update the implementation to avoid future redirections.`),{code:r.status,headers:r.headers,data:await extractResponseData(r,t.responseDataType)}},send=async(e,s,t)=>{try{return await __executeSend(e,s)}catch(n){if(extractMessage(n).includes("429")||!Array.isArray(t)||0===t.length)throw n;return await delay(t[0]),send(e,s,t.slice(1))}},sendGET=async(e,s,t)=>send(e,{...s,requestOptions:{...s?.requestOptions,method:"GET"}},t),sendPOST=(e,s,t)=>send(e,{...s,requestOptions:{...s?.requestOptions,method:"POST"}},t),sendPUT=(e,s,t)=>send(e,{...s,requestOptions:{...s?.requestOptions,method:"PUT"}},t),sendPATCH=(e,s,t)=>send(e,{...s,requestOptions:{...s?.requestOptions,method:"PATCH"}},t),sendDELETE=(e,s,t)=>send(e,{...s,requestOptions:{...s?.requestOptions,method:"DELETE"}},t);export{send,sendGET,sendPOST,sendPUT,sendPATCH,sendDELETE};
{
"name": "fetch-request-browser",
"version": "1.0.2",
"version": "1.0.3",
"description": "The fetch-request-browser package makes working with external APIs simple and efficient. This intuitive wrapper leverages the power of the Fetch API, providing a clean and concise interface for your API interactions.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -27,3 +27,3 @@ # Fetch Request Browser

```typescript
import { sendGET } from 'fetch-request-browser';
import { send } from 'fetch-request-browser';

@@ -30,0 +30,0 @@ await send(

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