Skip to content

Instantly share code, notes, and snippets.

View nhattruongniit's full-sized avatar

Tony Nguyen nhattruongniit

View GitHub Profile
var removeDb = function(databaseName) {
var req = indexedDB.deleteDatabase(databaseName);
req.onsuccess = function () {
console.log("Deleted database successfully. Base" + databaseName);
};
req.onerror = function () {
console.log("Couldn't delete database. Base" + databaseName);
};
@nhattruongniit
nhattruongniit / expired.js
Created June 24, 2019 07:10 — forked from srph/expired.js
axios + react-router: handling invalid tokens through axios interceptors
import axios from 'axios';
import cookie from 'cookie-machine';
import {hashHistory} from 'react-router';
axios.interceptors.response.use(null, function(err) {
if ( err.status === 401 ) {
cookie.remove('my-token-key');
hashHistory.push('/login');
}