0

I wish to send/receive data from the local storage. For eg: If I have an object named 'names', how do I process it?

Gibberish
  • 21
  • 3
  • possible duplicate : https://stackoverflow.com/questions/2010892/storing-objects-in-html5-localstorage – Shail_bee Jun 14 '19 at 09:02
  • 1
    Welcome to stackoverflow. Please take a look at: https://stackoverflow.com/tour – briosheje Jun 14 '19 at 09:02
  • There are tons of tutorials available for the [Storage API](https://developer.mozilla.org/en-US/docs/Web/API/Storage_API) – Andreas Jun 14 '19 at 09:03

2 Answers2

5

Welcome to StackOverflow @Gibberish!

As provided by @Andreas, you can visit the link. But, I would like to give you a kickstart

To receive data from localStorage

const names = localStorage.getItem('names'); //names will be a String. Don't forget to parse it!

To send data to localStorage

localStorage.setItem('names', JSON.stringify(names))
Abishek H
  • 210
  • 1
  • 10
0

There is a standard API for using the local storage and has simple usage, ex: wanna set a value you would call localStorage.setItem(k, v) and when getting item from storage you would call localStorage.getItem(k) where k is short for key and v for value

You can read more here how to use local storage

Mr.Fabulous
  • 116
  • 8