How to use the js-cookie.parse 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 remy / next-training / hocs / withUser.js View on Github external
function getToken({ req, token }) {
  if (token) {
    return token;

  if (req) {
    const cookie = require('cookie');

    if (!req.headers || !req.headers.cookie) {

    const { token } = cookie.parse(req.headers.cookie);
    return token;
  } else {
    const cookie = require('js-cookie');
    return cookie.get('token');