Answers for "js how to store and retrieve data from local storage"

0

store data to the browser’s localStorage

export const setToLS = (key, value) => {
  window.localStorage.setItem(key, JSON.stringify(value));
}

export const getFromLS = key => {
  const value = window.localStorage.getItem(key);

  if (value) {
    return JSON.parse(value);
  }
}
Posted by: Guest on June-25-2021

Code answers related to "js how to store and retrieve data from local storage"

Code answers related to "Javascript"

Browse Popular Code Answers by Language