Search Wikipedia articles

This script prompts the user for a search query and then returns the first 20 results from Wikipedia. It is buggy though, and I am an amateur dev so please be gentle. Help is needed to display the thumbnails in the preview section. Please don't hesitate to provide any feedback..

// Name: Search for Wikipedia articles
// Description: Prompts for a search string and lists articles from Wikipedia
// Author: Positron
// Shortcut:
import "@johnlindquist/kit"
let searchQuery = await arg("Enter a search query: ");
const url = `https://en.wikipedia.org/w/api.php?action=query&generator=search&gsrlimit=20&prop=pageimages%7Cextracts&exintro&explaintext&exlimit=max&format=json&gsrsearch=${searchQuery}`;
const result = await get(url);
let articleId = await arg("Please choose an article: ", Object.keys(result.data.query.pages).map(
(id) => ({
name: result.data.query.pages[id].title,
description: `https://en.wikipedia.org/wiki/${result.data.query.pages[id].title}`,
preview: () => `
<h3>${result.data.query.pages[id].title}</h3>
<p>${result.data.query.pages[id].extract}</p>`,
value: result.data.query.pages[id].pageid
})
))
browse(`https://en.wikipedia.org/?curid=${articleId}`)