Skip to content

Commit

Permalink
Merge pull request #2430 from jmedinac1987/main
Browse files Browse the repository at this point in the history
Reto #10 - JavaScript
  • Loading branch information
Roswell468 authored Mar 7, 2023
2 parents e86480b + 8486a7f commit fda76dd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Retos/Reto #10 - LA API [Media]/javascript/jmedinac1987.js
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit fda76dd

Please sign in to comment.