export const getItem = (key, def = null) => {
  let item = null;
  try {
    item = window.localStorage.getItem(key);
  } catch (err) {
    console.error('Unhandled exception when setting local storage item!', err);
  }

  if (item === null) {
    return def;
  }

  return JSON.parse(item);
};

export const setItem = (key, item) => {
  try {
    window.localStorage.setItem(key, JSON.stringify(item));
  } catch (err) {
    console.error('Unhandled exception when setting local storage item!', err);
  }
};
