How to use cookiejs - 3 common examples

To help you get started, we’ve selected a few cookiejs 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 kktjs / kkt-ssr / example / react-router+rematch / src / store / index.js View on Github external
middleware: () => next => async (action) => {
          if (typeof window !== 'undefined') {
            const token = cookie.get('token');
            if (token) {
              await cookie.set('token', token, 1);
            }
          }
          // do something here
          return next(action);
        },
      },
github kktjs / kkt-ssr / example / react-router+rematch / src / routes / home / index.js View on Github external
static async getInitialProps({ req, res, match, store, history, location }) {
    let token = null;
    // only on the server side
    if (req && store.dispatch.global && store.dispatch.global.verify && req.cookies) {
      token = req.cookies.token;
    }
    if (typeof window !== 'undefined') {
      token = cookie.get('token');
    }
    await store.dispatch.global.verify({ token });
    return { whatever: 'Home stuff', isServer: true };
  }
  render() {
github kktjs / kkt-ssr / example / react-router+rematch / src / store / index.js View on Github external
middleware: () => next => async (action) => {
          if (typeof window !== 'undefined') {
            const token = cookie.get('token');
            if (token) {
              await cookie.set('token', token, 1);
            }
          }
          // do something here
          return next(action);
        },
      },

cookiejs

A simple, lightweight JavaScript API for handling browser cookies.

MIT
Latest version published 5 months ago

Package Health Score

64 / 100
Full package analysis

Popular cookiejs functions