Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ vinted.search('https://www.vinted.fr/vetements?brand_id[]=53').then((posts) => {
console.log(posts); // all the posts that match this query
});
```

11 changes: 6 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const fetchCookie = (domain = 'fr') => {
const controller = new AbortController();
const agent = process.env.VINTED_API_HTTPS_PROXY ? new HttpsProxyAgent(process.env.VINTED_API_HTTPS_PROXY) : undefined;
if (agent) {
console.log(`[*] Using proxy ${process.env.VINTED_API_HTTPS_PROXY}`);
// console.log(`[*] Using proxy ${process.env.VINTED_API_HTTPS_PROXY}`);
}
fetch(`https://vinted.${domain}`, {
signal: controller.signal,
Expand All @@ -26,7 +26,7 @@ const fetchCookie = (domain = 'fr') => {
controller.abort();
const c = cookie.parse(sessionCookie)['secure, _vinted_fr_session'];
if (c) {
console.log(c);
// console.log(c);
cookies.set(domain, c);
}
resolve();
Expand Down Expand Up @@ -101,11 +101,12 @@ const search = (url, disableOrder = false, allowSwap = false, customParams = {})
return resolve([]);
}

const c = cookies.get(domain) ?? process.env[`VINTED_API_${domain.toUpperCase()}_COOKIE`];
if (c) console.log(`[*] Using cached cookie for ${domain}`);
var c = cookies.get(domain) ?? process.env[`VINTED_API_${domain.toUpperCase()}_COOKIE`];
// if (c) console.log(`[*] Using cached cookie for ${domain}`);
if (!c) {
console.log(`[*] Fetching cookie for ${domain}`);
// console.log(`[*] Fetching cookie for ${domain}`);
await fetchCookie(domain).catch(() => {});
c = cookies.get(domain) ?? process.env[`VINTED_API_${domain.toUpperCase()}_COOKIE`];
}

const controller = new AbortController();
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
"dependencies": {
"cookie": "^0.4.1",
"https-proxy-agent": "^5.0.0",
"jest": "^27.0.6",
"node-fetch": "^2.6.1",
"user-agents": "^1.0.642"
},
"devDependencies": {
"jest": "^27.0.6"
}
}
}
Loading