How to use the js-cookie.getJSON function in js-cookie

To help you get started, we’ve selected a few js-cookie examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bbc / simorgh / src / app / lib / analyticsUtils / index.js View on Github external
export const getAtUserId = () => {
  if (!onClient()) return null;

  const cookieName = 'atuserid';
  const cookie = Cookie.getJSON(cookieName);
  let val = pathOr(null, ['val'], cookie);
  const expires = 397; // expires in 13 months

  if (!cookie || !val) {
    val = uuid();
  }

  Cookie.set(cookieName, { val }, { expires, path: '/' });

  return val;
};
github bang88 / ant-console / src / actions / auth.js View on Github external
export function loggedIn() {
	return cookie.getJSON('token')
}
github PacktPublishing / Hands-On-Full-Stack-Development-with-Go / Chapter07 / Frontend / src / App.js View on Github external
constructor(props) {
    super(props);
    const user = cookie.getJSON("user") || {loggedin:false};
    this.state = {
      user: user,
      showSignInModal: false,
      showBuyModal: false
    };
    this.handleSignedIn = this.handleSignedIn.bind(this);
    this.handleSignedOut = this.handleSignedOut.bind(this);
    this.showSignInModalWindow = this.showSignInModalWindow.bind(this);
    this.toggleSignInModalWindow = this.toggleSignInModalWindow.bind(this);
    this.showBuyModalWindow = this.showBuyModalWindow.bind(this);
    this.toggleBuyModalWindow = this.toggleBuyModalWindow.bind(this);
    
  }
github keen / keen-tracking.js / lib / utils / cookie.js View on Github external
cookie.prototype.get = function(str){
  var data = {};

  if (Cookies.get(this.config.key)) {
    data = Cookies.getJSON(this.config.key);
  }
  if (str && typeof data === 'object' && typeof data !== null) {
    return (typeof data[str] !== 'undefined') ? data[str] : null;
  }
  else {
    return data;
  }
};
github HubSpot / Blazar-Archive / BlazarUI / app / scripts / components / WatchingProvider.js View on Github external
syncWatchingCache: function() {
    let watching = Cookies.getJSON('watching-repos');
    if (!watching) {
      watching = [];
    }
    watchingCache = watching;
  }
github leopku / revel / src / store / index.js View on Github external
getState: (key) => {
      const user = Cookies.getJSON(key)
      if ((user || {}).sessionToken) {
        Vue.axios.defaults.headers.common['X-Parse-Session-Token'] = user.sessionToken
      }
      return { auth: { user } }
    },
    setState: (key, state) => Cookies.set(key, state.auth.user, { expires: 30 })
github fakhir-shad / js-flash-messages / src / flash.js View on Github external
const flashes = storedFlash.map(flashName => {
      const flash = Cookies.getJSON(flashName);
      Cookies.remove(flashName);
      return flash;
    });
    Cookies.remove("jsFlashNames");
github patrickmichalina / fusebox-angular-universal-starter / src / client / app / shared / services / cookie.service.ts View on Github external
public get(name: string): any {
    if (this.platformService.isBrowser) {
      return getJSON(name)
    } else {
      try {
        return JSON.parse(this.req.cookies[name])
      } catch (err) {
        return this.req ? this.req.cookies[name] : undefined
      }
    }
  }