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

autofetch

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

autofetch - npm Package Compare versions

Comparing version 1.0.10 to 1.0.11

2

package.json
{
"name": "autofetch",
"version": "1.0.10",
"version": "1.0.11",
"description": "fetch for node",

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

const realFetch = require('isomorphic-fetch/fetch-npm-browserify.js');
const { responseMiddleware, parseUrl } = require('./utils');
const { responseMiddleware, parseUrl, toFormData } = require('./utils');

@@ -10,2 +10,12 @@ let globalCallback = response => response;

if(!options.method || options.method === 'GET'){
options.body = options.body || options.data;
}
options.headers = options.headers || {};
if(options.headers['Content-Type'] !== 'application/json' && !(options.body instanceof 'FormData') {
// convert to FormData
options.body = toFormData(body);
}
return realFetch.call(this, parseUrl(url, options, baseHost), options, ...extras).then(responseMiddleware).then(globalCallback);

@@ -12,0 +22,0 @@ };

@@ -12,2 +12,12 @@ "use strict";

if(!options.method || options.method === 'GET'){
options.body = options.body || options.data;
}
options.headers = options.headers || {};
if(options.headers['Content-Type'] !== 'application/json' && !(options.body instanceof 'FormData') {
// convert to FormData
options.body = toFormData(body);
}
return realFetch.call(this, parseUrl(url, options,baseHost), options, ...extras).then(responseMiddleware).then(globalCallback);

@@ -14,0 +24,0 @@ };

@@ -23,5 +23,15 @@ const responseMiddleware = (response) => {

const toFormData = (obj) => {
const form = new FormData();
Object.keys(obj).forEach((key)=> {
form.append(key, obj[key]);
});
return form;
}
module.exports = {
parseUrl,
responseMiddleware
responseMiddleware,
toFormData
};
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