@lion/ajax
Advanced tools
Comparing version 0.1.14 to 0.1.15
@@ -6,2 +6,10 @@ # Change Log | ||
## [0.1.15](https://github.com/ing-bank/lion/compare/@lion/ajax@0.1.14...@lion/ajax@0.1.15) (2019-07-24) | ||
**Note:** Version bump only for package @lion/ajax | ||
## [0.1.14](https://github.com/ing-bank/lion/compare/@lion/ajax@0.1.13...@lion/ajax@0.1.14) (2019-07-23) | ||
@@ -8,0 +16,0 @@ |
{ | ||
"name": "@lion/ajax", | ||
"version": "0.1.14", | ||
"version": "0.1.15", | ||
"description": "Thin wrapper around axios to allow for custom interceptors", | ||
@@ -36,3 +36,3 @@ "author": "ing-bank", | ||
"@bundled-es-modules/axios": "0.18.1", | ||
"@lion/core": "^0.1.11" | ||
"@lion/core": "^0.1.12" | ||
}, | ||
@@ -44,3 +44,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "da99c690df7eca55fcb5f9d8a10979f71d184a2c" | ||
"gitHead": "8d81f84ea9b2618d45774370666710c9c462532a" | ||
} |
@@ -17,2 +17,3 @@ # Ajax | ||
## Features | ||
- only JS functions, no (unnecessarily expensive) web components | ||
@@ -22,6 +23,6 @@ - supports GET, POST, PUT, DELETE, REQUEST, PATCH and HEAD methods | ||
## How to use | ||
### Installation | ||
```sh | ||
@@ -32,10 +33,12 @@ npm i --save @lion/ajax | ||
### Example | ||
```js | ||
import { ajax } from '@lion/ajax'; | ||
ajax.get('data.json') | ||
.then((response) => { | ||
ajax | ||
.get('data.json') | ||
.then(response => { | ||
console.log(response); | ||
}) | ||
.catch((error) => { | ||
.catch(error => { | ||
console.log(error); | ||
@@ -48,2 +51,3 @@ }); | ||
#### Cancel | ||
```js | ||
@@ -53,7 +57,8 @@ import { AjaxClass } from '@lion/ajax'; | ||
const myAjax = AjaxClass.getNewInstance({ cancelable: true }); | ||
myAjax.get('data.json') | ||
.then((response) => { | ||
myAjax | ||
.get('data.json') | ||
.then(response => { | ||
document.querySelector('#canceled').innerHTML = JSON.stringify(response.data); | ||
}) | ||
.catch((error) => { | ||
.catch(error => { | ||
document.querySelector('#canceled').innerHTML = `I got cancelled: ${error.message}`; | ||
@@ -67,18 +72,21 @@ }); | ||
#### Cancel previous on new request | ||
```js | ||
import { AjaxClass } from '@lion/ajax' | ||
import { AjaxClass } from '@lion/ajax'; | ||
const myAjax = AjaxClass.getNewInstance({ cancelPreviousOnNewRequest: true }); | ||
myAjax.get('data.json') | ||
.then((response) => { | ||
myAjax | ||
.get('data.json') | ||
.then(response => { | ||
document.querySelector('#request1').innerHTML = 'Request 1: ' + JSON.stringify(response.data); | ||
}) | ||
.catch((error) => { | ||
.catch(error => { | ||
document.querySelector('#request1').innerHTML = `Request 1: I got cancelled: ${error.message}`; | ||
}); | ||
myAjax.get('data2.json') | ||
.then((response) => { | ||
myAjax | ||
.get('data2.json') | ||
.then(response => { | ||
document.querySelector('#request2').innerHTML = 'Request 2: ' + JSON.stringify(response.data); | ||
}) | ||
.catch((error) => { | ||
.catch(error => { | ||
document.querySelector('#request2').innerHTML = `Request 2: I got cancelled: ${error.message}`; | ||
@@ -85,0 +93,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44490
98
Updated@lion/core@^0.1.12