New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

xhr-promise-redux

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xhr-promise-redux - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

package.json
{
"name": "xhr-promise-redux",
"version": "1.0.0",
"version": "1.0.1",
"description": "XMLHttpRequest implementation wrapped in a promise.js Promise object",

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

@@ -27,54 +27,57 @@ Originally forked from [frikille/promised-xhr](https://github.com/frikille/promised-xhr)

1. Sending a GET request
```javascript
xhr.get('/test-url', {
data: {
param: 'value'
},
headers: {
'Header-name': 'Header value'
},
responseType: 'json'
})
.then(function (response) {
console.log(`Success! The response JSON object: ${response.body}`);
})
.catch(function(response) {
console.log(`Error! Response Status Code: ${response.statusCode}`)
});
```
```javascript
xhr.get('/test-url', {
data: {
param: 'value'
},
headers: {
'Header-name': 'Header value'
},
responseType: 'json'
})
.then(function (response) {
console.log(`Success! The response JSON object: ${response.body}`);
})
.catch(function(response) {
console.log(`Error! Response Status Code: ${response.statusCode}`)
});
```
2. Sending a POST request with JSON
```javascript
xhr.post('/test-url', {
json: {
param: 'value'
},
headers: {
'Header-name': 'Header value'
},
responseType: 'json'
})
.then(function (response) {
console.log(`Success! The response JSON object: ${response.body}`);
})
.catch(function(response) {
console.log(`Error! Response Status Code: ${response.statusCode}`)
});
```
```javascript
xhr.post('/test-url', {
json: {
param: 'value'
},
headers: {
'Header-name': 'Header value'
},
responseType: 'json'
})
.then(function (response) {
console.log(`Success! The response JSON object: ${response.body}`);
})
.catch(function(response) {
console.log(`Error! Response Status Code: ${response.statusCode}`)
});
```
3. Sending a request with any method
```javascript
xhr.send('/test-url', {
method: 'PUT',
json: {
param: 'value'
},
headers: {
'Header-name': 'Header value'
}
})
.then(function (response) {
console.log(`Success! The response JSON object: ${response.body}`);
})
.catch(function(response) {
console.log(`Error! Response Status Code: ${response.statusCode}`)
});
```
```javascript
xhr.send('/test-url', {
method: 'PUT',
json: {
param: 'value'
},
headers: {
'Header-name': 'Header value'
}
})
.then(function (response) {
console.log(`Success! The response JSON object: ${response.body}`);
})
.catch(function(response) {
console.log(`Error! Response Status Code: ${response.statusCode}`)
});
```
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