Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access localStorage in node.js?

I tried searching the web for a node module that can access the client's localStorage but wasn't able to find anything. Anyone know of one?

like image 470
Chris Abrams Avatar asked Apr 27 '12 21:04

Chris Abrams


People also ask

How do I access local storage node JS?

Also you need: open new Terminal press Control + C (don't worry it's for clear not for copy) and type you'r file. js (for ex: server. js) and than type this: npm i node-localstorage (now you all set).

How do I access localStorage?

It's simple. Just go to the developer tools by pressing F12 , then go to the Application tab. In the Storage section expand Local Storage. After that, you'll see all your browser's local storage there.

Can we access local storage from backend?

LocalStorage is a frontend concept. It is accessible to JavaScript running in the browser. Node. js resides on backend and can not access the LocalStorage directly.

How do I access localStorage in JavaScript?

There are four basic JavaScript methods you can use to access and work with localStorage: setItem() - takes a key-value pair and adds it to localStorage. getItem() - takes a key and returns the corresponding value. removeItem() - takes a key and removes the corresponding key-value pair.


1 Answers

You can use :

node-localstorage npm module to use localStorage at the nodejs server side.

var LocalStorage = require('node-localstorage').LocalStorage, localStorage = new LocalStorage('./scratch'); 
like image 122
VijeshJain Avatar answered Sep 19 '22 13:09

VijeshJain