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

minixhr

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

minixhr - npm Package Compare versions

Comparing version 3.1.0 to 3.2.0

6

minixhr.js

@@ -1,5 +0,4 @@

var XMLHttpRequest = require('xhrpolyfill')
module.exports = function xhr2 (params, callback) {
var url = typeof params === 'string' ? params : params.url
var method = params.method || (params.data ? 'POST': 'GET')
var method = params.method || (params.data ? 'POST' : 'GET')
var body = params.data

@@ -10,4 +9,3 @@ var H = params.headers ? params.headers : params.body ? {

} : {}
var xhr = XMLHttpRequest()
if (!xhr) throw new Error('No AJAX support')
var xhr = new XMLHttpRequest()
xhr.open(method, url)

@@ -14,0 +12,0 @@ for (var key in H) xhr.setRequestHeader(key, H[key])

{
"name": "minixhr",
"version": "3.1.0",
"version": "3.2.0",
"description": "super simpel and small cross-browser xhr",

@@ -18,2 +18,3 @@ "main": "minixhr.js",

"http",
"request",
"browser",

@@ -28,6 +29,3 @@ "cross-browser",

},
"homepage": "https://github.com/serapath/minixhr",
"dependencies": {
"xhrpolyfill": "^1.3.0"
}
"homepage": "https://github.com/serapath/minixhr"
}

@@ -8,25 +8,21 @@ # minixhr

var callback = function responseHandler (data, response, xhr, header) {
console.log(data)
}
// EXAMPLE 1
// response handler
function callback (data, response, xhr, header) { console.log(data) }
minixhr('http://jsonplaceholder.typicode.com/posts/1', callback)
// check http://requestb.in/18b4srl1?inspect afterwards to inspect
var data = {
foo: 123,
bar: "abc"
}
// EXAMPLE 2
var data = { foo: 123, bar: "abc" }
var request = { // can be 'url string' or object:
url : 'http://requestb.in/18b4srl1',
method : 'POST', // [optional] (defaults to 'GET')
data : JSON.stringify(data), // [optional] payload data could be <formdata> or {key:val}'s or anything
headers : {} // [optional] (defaults to '{}' or in case of 'POST':
// {'X-Requested-With':'XMLHttpRequest','Content-Type':'application/x-www-form-urlencoded' } )
/*required*/url : 'http://requestb.in/18b4srl1',
/*optional*/method : 'POST', // (defaults to 'GET')
/*optional*/data : JSON.stringify(data), // payload data could be <formdata> or {key:val}'s or any string
/*optional*/headers : {} // (defaults to '{}' OR in case of 'POST' it defaults to:
// {'X-Requested-With':'XMLHttpRequest','Content-Type':'application/x-www-form-urlencoded' } )
}
minixhr(request) // [optional] callback - (e.g. leave out for POST Request where you don't care about a response
```
// EXAMPLE 1
minixhr(request, callback) // [optional] callback - (e.g. leave out for POST Request where you don't care about a response
// EXAMPLE 2
minixhr('http://jsonplaceholder.typicode.com/posts/1', callback)
// check http://requestb.in/18b4srl1?inspect afterwards to inspect
```
if you need to support old browsers, use version `3.1.0` or below.
Those versions still include the [xhr polyfill](https://www.npmjs.com/package/xhrpolyfill)
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