Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arojunior/handle-failed-requests-js
Implementation of Offline-js with some improvements
https://github.com/arojunior/handle-failed-requests-js
axios javascript offline offline-js
Last synced: about 2 months ago
JSON representation
Implementation of Offline-js with some improvements
- Host: GitHub
- URL: https://github.com/arojunior/handle-failed-requests-js
- Owner: arojunior
- License: mit
- Created: 2017-02-06T18:09:43.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-10-26T02:34:46.000Z (about 5 years ago)
- Last Synced: 2024-10-22T17:50:57.257Z (2 months ago)
- Topics: axios, javascript, offline, offline-js
- Language: JavaScript
- Size: 98.6 KB
- Stars: 29
- Watchers: 4
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# handle-failed-requests-js
[![npm version](https://img.shields.io/npm/v/handle-failed-requests-js.svg)](https://www.npmjs.com/package/handle-failed-requests-js) [![npm downloads](https://img.shields.io/npm/dm/handle-failed-requests-js.svg)](https://www.npmjs.com/package/handle-failed-requests-js) [![Standard - JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
Implementation of [Offline-js](https://github.com/hubspot/offline) with some improvements
# Why?
Because Offline-js has some bugs and inconsistencies
# Features
* Promises support (axios)
* localStorage support
* Save ALL the failed requests, not just the last one
* Requests keep saved even if user try to refresh the page when offline
* Send ALL failed requests when connection is up again
* No need configuration![Alt text](https://user-images.githubusercontent.com/7604033/39336674-19212d44-498f-11e8-9239-5bdc0710be2f.gif 'Example')
# How
* Node / npm
```shell
npm install --save handle-failed-requests-js
``````javascript
import Request from 'handle-failed-requests-js';Request.send({
method: 'put',
data: data,
url: '/'
}).then(res => {
console.log(res);
});
```[example.html](https://github.com/arojunior/handle-failed-requests-js/blob/master/example.html)
```html
```
```javascript
var req = new Request();// default method is post
req.send('/', data).then(function(res) {
console.log(res);
});// or
req
.send({
method: 'put',
data: data,
url: '/'
})
.then(function(res) {
console.log(res);
});
```See [Axios](https://github.com/mzabriskie/axios) documentation for requests options
[Artigo em português](https://medium.com/@arojunior/enviando-requisi%C3%A7%C3%B5es-sem-se-preocupar-com-o-status-da-conex%C3%A3o-2c8aca05457)