Skip to content

Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.

Fixed forEachKey

Jan Novotny68d9bfe5c585
diff --git a/src/key_value_store.js b/src/key_value_store.js
index 36f8fda5f..cee00b3ea 100644
--- a/src/key_value_store.js
+++ b/src/key_value_store.js
@@ -319,7 +319,7 @@ export class KeyValueStore {
checkParamOrThrow(index, 'index', 'Number');
const response = await keyValueStores.listKeys({ storeId: this.storeId, exclusiveStartKey });
- const { nextExclusiveStartKey, isTruncated, items } = response.data;
+ const { nextExclusiveStartKey, isTruncated, items } = response;
for (const key of items) {
await iteratee(key, index++);
}
diff --git a/test/key_value_store.js b/test/key_value_store.js
index 2d791b95d..71c8e8640 100644
--- a/test/key_value_store.js
+++ b/test/key_value_store.js
@@ -380,11 +380,9 @@ describe('KeyValueStore', () => {
exclusiveStartKey: 'key0',
})
.resolves({
- data: {
- isTruncated: true,
- nextExclusiveStartKey: 'key2',
- items: ['key1', 'key2'],
- },
+ isTruncated: true,
+ nextExclusiveStartKey: 'key2',
+ items: ['key1', 'key2'],
});
mock.expects('listKeys')
.once()
@@ -393,11 +391,10 @@ describe('KeyValueStore', () => {
exclusiveStartKey: 'key2',
})
.resolves({
- data: {
- isTruncated: true,
- nextExclusiveStartKey: 'key4',
- items: ['key3', 'key4'],
- } });
+ isTruncated: true,
+ nextExclusiveStartKey: 'key4',
+ items: ['key3', 'key4'],
+ });
mock.expects('listKeys')
.once()
.withArgs({
@@ -405,11 +402,10 @@ describe('KeyValueStore', () => {
exclusiveStartKey: 'key4',
})
.resolves({
- data: {
- isTruncated: false,
- nextExclusiveStartKey: null,
- items: ['key5'],
- } });
+ isTruncated: false,
+ nextExclusiveStartKey: null,
+ items: ['key5'],
+ });
const results = [];
await store.forEachKey(async (key, index) => {