untitled notebook

node v8.17.0
version: 2.0.2
endpointsharetweet
ax = require('axios'); exports.endpoint = async function(request, response) { function rnd(a){ return a[Math.floor(Math.random() * a.length)]; } facts = await ax.get('https://gist.githubusercontent.com/selfish/d32b4cb902f4fb4df03598cf1337f285/raw/e1ba9c8bf5b7730fe29537a1380e182aaed3b56a/facts.json'); facts = facts.data; category = rnd(Object.keys(facts)) fact = rnd(facts[category]) response.end(JSON.stringify({category, fact})); }
Loading…

no comments

    sign in to comment