Search Wikipedia Nice little method you can use to search Wikipedia for facts and information You don t need an overly complex library or a powerful server you can piggy pack on the fetch method Search Wikipedia async function searchWikipedia searchQuery const endpoint https en wikipedia org w api php action query list search prop info inprop url utf8 format json origin srlimit 20 srsearch searchQuery const response await fetch endpoint if response ok throw Error response statusText const json await response json return json let res await searchWikipedia cats console log res Search Wikipedia async function searchWikipedia searchQuery const endpoint https en wikipedia org w api php action query list search prop info inprop url utf8 format json origin srlimit 20 srsearch searchQuery const response await fetch endpoint if response ok throw Error response statusText const json await response json return json let res await searchWikipedia cats console log res query search length console log res query search 0 const pageid res query search 0 pageid console log pageid pageid const url https en wikipedia org curid pageid let link document createElement a link textContent res query search 0 title link href url document body appendChild link Search Wikipedia document body style height 400px async function searchWikipedia searchQuery const endpoint https en wikipedia org w api php action query list search prop info inprop url utf8 format json origin srlimit 20 srsearch searchQuery const response await fetch endpoint if response ok throw Error response statusText const json await response json return json let res await searchWikipedia cats console log res query search length for let i 0 i res query search length i const pageid res query search i pageid const title res query search i title const url https en wikipedia org curid pageid let link document createElement a link textContent title link href url document body appendChild link document body appendChild document createElement br console log ready
es query search 0 pageid console log pageid pageid const url https en wikipedia org curid pageid let link document createElement a link textContent res query search 0 title link href url document body appendChild link Search Wikipedia document body style height 400px async function searchWikipedia searchQuery const endpoint https en wikipedia org w api php action query list search prop info inprop url utf8 format json origin srlimit 20 srsearch searchQuery const response await fetch endpoint if response ok throw Error response statusText const json await response json return json let res await searchWikipedia cats console log res query search length for let i 0 i res query search length i const pageid res query search i pageid const title res query search i title const url https en wikipedia org curid pageid let link document createElement a link textContent title link href url document body appendChild link document body appendChild document createElement br console log ready