use RESTful way to build a storage adaptor for redux-persist by implementing methods: setItem
, getItem
, removeItem
and getAllKeys
npm install --save redux-persist-restful-storage
import { AsyncRESTfulStorage } from 'redux-persist-restful-storage'
import { persistStore, autoRehydrate } from 'redux-persist'
const store = createStore(reducer, undefined, autoRehydrate())
persistStore(store, { storage: new AsyncRESTfulStorage() })
You need to build your own RESTful API server to communicate with redux-persist.
/example
present an example with nodeJS. Use express to create a HTTP server and node-localstorage to save/get data.
To run with
npm init
npm install body-parser express node-localstorage
node nodeApiExample.js