{"size": 315, "ext": "js", "max_stars_repo_path": "lib/getTokenFromCookie.js", "max_stars_repo_name": "jchapple/nextjs-apollo-bulma-boilerplate", "max_stars_repo_stars_event_min_datetime": "2019-02-24T00:43:33.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-30T19:50:20.000Z", "max_issues_repo_path": "lib/getTokenFromCookie.js", "max_issues_repo_name": "jchapple/nextjs-apollo-bulma-boilerplate", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lib/getTokenFromCookie.js", "max_forks_repo_name": "jchapple/nextjs-apollo-bulma-boilerplate", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 5, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.2307692308, "max_line_length": 68, "alphanum_fraction": 0.7111111111}
import cookie from 'cookie'

export default function getTokenFromCookie(headers) {
  const cookies = process.browser ? document.cookie : headers.cookie

  if (cookies) {
    const { token, refreshToken } = cookie.parse(cookies)
    return token && refreshToken ? { token, refreshToken } : null
  }

  return null
}
