How to use the universal-cookie.default function in universal-cookie

To help you get started, we’ve selected a few universal-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 matthewmueller / next-cookies / index.js View on Github external
var Cookies = require("universal-cookie");
// we seem to sometimes get the ES6 version despite requesting cjs here, not sure why
// this isn't the ideal fix, but it'll do for now
Cookies = Cookies.default || Cookies;

function nextCookies(ctx, options) {
  // Note: Next.js Static export sets ctx.req to a fake request with no headers
  var header = ctx.req && ctx.req.headers && ctx.req.headers.cookie;
  var uc = new Cookies(header);
  return uc.getAll(options);
}

module.exports = nextCookies;

universal-cookie

Universal cookies for JavaScript

MIT
Latest version published 23 days ago

Package Health Score

85 / 100
Full package analysis