-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest-search.cjs
More file actions
27 lines (21 loc) · 815 Bytes
/
test-search.cjs
File metadata and controls
27 lines (21 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const { OorlogsbronnenClient } = require('./dist/lib/oorlogsbronnen-api');
async function main() {
const client = new OorlogsbronnenClient();
console.error('Searching for "101st Airborne Division"...');
const results = await client.search({
query: '101st Airborne Division'
});
console.error(`Found ${results[1].total} total results`);
console.error(`First 10 results:`);
const items = results[0].items;
items.forEach((item, index) => {
const attributes = item.tuple[0].attributes;
const title = attributes['http://purl.org/dc/elements/1.1/title'] || 'Untitled';
const type = item.tuple[0].class[0].split('/').pop();
console.error(`${index + 1}. [${type}] ${title}`);
});
}
main().catch(err => {
console.error('Error occurred:', err);
process.exit(1);
});