Closed brunonevesy closed 4 months ago
The reason you aren't seeing the callback being called is because the following line causes an error to be thrown before removeCookie
is called.
cookieJar.setCookieSync('__cf_bm=XPTO3; path=/; expires=Thu, 30-May-24 20:10:02 GMT; domain=.eu.ABC.com; HttpOnly; Secure; SameSite=None', 'https://ABC.com');
The reason you aren't seeing the callback being called is because the following line causes an error to be thrown before
removeCookie
is called.cookieJar.setCookieSync('__cf_bm=XPTO3; path=/; expires=Thu, 30-May-24 20:10:02 GMT; domain=.eu.ABC.com; HttpOnly; Secure; SameSite=None', 'https://ABC.com');
Hi,
Thank you so much for your reply
I remove that cookie but i still have the problem, i have more than one cookie in var cookie = cookieJar.getCookies('https://ABC.com'); but after in:
cookieJar.store.removeCookie(cookie.domain, cookie.path, cookie.key, (err)
i can't acess the cookie array
Can you help me?
Thank you so much
@brunonevesy, For the following code:
var cookie = cookieJar.getCookies('https://ABC.com');
Because you aren't providing a callback, the value of cookie
will be a Promise<Cookie[]>
(see docs), not an array of cookies.
But once you get the array of cookies back, the code you provided below still won't work unless you make significant changes:
// this check is not necessary, the result of successfully retrieving cookies is always Cookie[]
if (cookie) {
// the cookies are not being iterated over, so `cookie` is currently an array value
// which doesn't have properties named `domain` or `path` or `key`
cookieJar.store.removeCookie(cookie.domain, cookie.path, cookie.key, (err) => {
if (err) {
console.error('Erro ao remover cookie:', err);
return;
}
console.log(`Cookie removido com sucesso`);
})
}
// the above code is callback-based (async) so if you want this console.log output to show up
// after all the cookies have been removed that will likely not happen in the order you expect
// unless you add code to wait for all the callbacks to complete
console.log("breakpoint");
The methods removeCookie never show up, below is the code:
async function Funcao() { try {
}Funcao()