fetchData

node v15.12.0
version: 1.0.0
endpointsharetweet
const fetch = require('node-fetch'); const res = await fetchData('https://some-random-api.ml/lyrics?title=toosie%20slide', 'author'); // ==> "Drake" console.log(res); // Logs "Drake" into console function fetchData(url, value) { const val = fetch(url) .then((res) => res.json()) .then((data) => { return data[value]; }).catch((err) => console.warn(err)); return val; }
Loading…

no comments

    sign in to comment