MCPcopy Create free account
hub / github.com/MuYunyun/create-react-doc / getCookie

Function getCookie

packages/leetcode-cli/src/leetcode.js:67–88  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

65}
66
67const getCookie = async () => {
68 // eslint-disable-line
69 try {
70 const { cookies } = getConfig()
71 const { LEETCODE_SESSION } = cookies
72 if (
73 !LEETCODE_SESSION ||
74 new Date(LEETCODE_SESSION.expires) <= new Date().getTime() / 1000
75 ) {
76 console.error('Cookie expires, retry...')
77 removeConfig('cookies')
78 return getCookie()
79 }
80 return Object.keys(cookies).reduce((acc, name) => {
81 acc[name] = cookies[name].value
82 return acc
83 }, {})
84 } catch (error) {
85 const cookies = await login()
86 return cookies
87 }
88}
89
90const createGqlRequest = async () => {
91 const cookies = await getCookie()

Callers 1

createGqlRequestFunction · 0.85

Calls 3

getConfigFunction · 0.85
removeConfigFunction · 0.85
loginFunction · 0.85

Tested by

no test coverage detected