| 1 |
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved */ |
| 2 |
import fetch from 'node-fetch'; |
| 3 |
import cheerio from 'cheerio'; |
| 4 |
import retry from '..'; |
| 5 |
/* eslint-enable import/no-extraneous-dependencies, import/no-unresolved */ |
| 6 |
|
| 7 |
const getRandomTitle = async () => |
| 8 |
retry(async () => { |
| 9 |
const res = await fetch('https://en.wikipedia.org/wiki/Special:Random'); |
| 10 |
const text = await res.text(); |
| 11 |
const $ = cheerio.load(text); |
| 12 |
return $('h1').text(); |
| 13 |
}); |
| 14 |
|
| 15 |
// eslint-disable-next-line no-console |
| 16 |
getRandomTitle().then(console.log); |