Skip to content

arojunior/handle-failed-requests-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ed778d4 · Oct 13, 2018

History

23 Commits
Apr 25, 2018
Apr 25, 2018
Feb 6, 2017
Feb 6, 2017
Oct 13, 2018
Apr 26, 2018
Apr 25, 2018
Apr 26, 2018
Oct 13, 2018
Feb 6, 2017

Repository files navigation

handle-failed-requests-js

npm version npm downloads Standard - JavaScript Style Guide

Implementation of Offline-js 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

How

  • Node / npm
npm install --save handle-failed-requests-js
import Request from 'handle-failed-requests-js';

Request.send({
  method: 'put',
  data: data,
  url: '/'
}).then(res => {
  console.log(res);
});

example.html

<script src="handle-requests.min.js"></script>
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 documentation for requests options

Artigo em português

About

Implementation of Offline-js with some improvements

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published