-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwikipedia.js
More file actions
27 lines (24 loc) · 791 Bytes
/
Copy pathwikipedia.js
File metadata and controls
27 lines (24 loc) · 791 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 wiki = require('wikipedia');
(async () => {
try {
// const page = await wiki.page('spicer man');
// const summary = (await page.summary()).extract;
// console.log(summary);
//Response of type @wikiSummary - contains the intro and the main image
const searchResults = await wiki.search('Spider-Man');
console.log(searchResults);
} catch (error) {
console.log(error);
//=> Typeof wikiError
}
})();
// async function searchwiki(searchTerm) {
// try {
// const page = await wiki.page(searchTerm);
// const summary = await page.summary();
// return summary;
// } catch (error) {
// console.error(error);
// return 'An error occurred while fetching the Wikipedia summary.';
// }
// }