Skip to content

Commit

Permalink
Merge pull request #6655 from nox456/main
Browse files Browse the repository at this point in the history
Reto #10 - javascript
  • Loading branch information
kontroldev authored Aug 21, 2024
2 parents 8e3fd50 + 8b012f1 commit e5874c8
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Retos/Reto #10 - LA API [Media]/javascript/nox456.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// The Legend Of Zelda API (https://docs.zelda.fanapis.com/)
const BASE_URL = "https://zelda.fanapis.com/api"

async function getGames(name) {
const gamesUrl = `${BASE_URL}/games`
let data
if (name) {
try {
const res = await fetch(`${gamesUrl}?name=${name}`)
data = await res.json()
} catch(e) {
return e
}
} else {
try {
const res = await fetch(gamesUrl)
data = await res.json()
} catch(e) {
return e
}
}
return data
}

(async () => {
console.log(await getGames("Ocarina"))
})()

0 comments on commit e5874c8

Please sign in to comment.