-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2430 from jmedinac1987/main
Reto #10 - JavaScript
- Loading branch information
Showing
1 changed file
with
18 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
Retos/Reto #10 - LA API [Media]/javascript/jmedinac1987.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |