Skip to content

Instantly share code, notes, and snippets.

@carbide-public
Last active January 31, 2023 07:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carbide-public/46794808941e2b02a286324e9e3fb92d to your computer and use it in GitHub Desktop.
Save carbide-public/46794808941e2b02a286324e9e3fb92d to your computer and use it in GitHub Desktop.
untitled
let word = "cat"
let endpoint = 'https://en.wiktionary.org/api/rest_v1/page/definition'
let filter = new RegExp('< *\\/? *[a-z]+ *( [a-z]+="[^<>"]+" *)* *\\/? *>', 'ig')
let url = `${endpoint}/${word}`
let resObj = await fetch(url, {orgin:'test'})
let res = await resObj.json()
function cleanString(str) {
return str.replaceAll(filter, '').replaceAll('&nbsp;', ' ')
}
let output = res
console.log(output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment