I’m building a app that make request to the leetcode graphql api. Inside this function header I’ve use the user stored cookie from my backend. My concern is how long does the cookie last, and how long do I need to re-update the cookie session?
async function userQuestionStatus(userSession, title_slug) {
const query = {
operationName: "userQuestionStatus",
query:
"n query userQuestionStatus($titleSlug: String!) {n question(titleSlug: $titleSlug) {n statusn }n}n ",
variables: {
titleSlug: title_slug,
},
};
const headers = {
"Content-Type": "application/json",
Referer: "https://leetcode.com/",
Cookie: userSession || "",
};
const response = await fetch("https://leetcode.com/graphql", {
method: "POST",
headers: headers,
body: JSON.stringify(query),
});
const data = await response.json();
return data;
}
New contributor
Xu Wang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.