diff --git a/Retos/Reto #10 - LA API [Media]/javascript/jmedinac1987.js b/Retos/Reto #10 - LA API [Media]/javascript/jmedinac1987.js new file mode 100644 index 0000000000..3843f700b4 --- /dev/null +++ b/Retos/Reto #10 - LA API [Media]/javascript/jmedinac1987.js @@ -0,0 +1,18 @@ +//Note: To run the following code in the Node.js console you must first install node-fetch with the following command 'npm install node-fetch' +import fetch from "node-fetch"; + +async function getWaifu(isNsfw) { + try { + let response = await fetch(`https://api.waifu.im/search?is_nsfw=${isNsfw}`); + let waifus = await response.json(); + + return waifus; + } catch (error) { + return error; + } +} + +let waifu = await getWaifu(false);//for children under 18 years of age +let waifuX = await getWaifu(true);//for over 18 years +console.log(waifu); +console.log(waifuX); \ No newline at end of file