Last active
July 17, 2020 19:06
-
-
Save 0x14Rp/0a6f7a8fce13f76811ff22353043e59e to your computer and use it in GitHub Desktop.
example for recursive function π
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
const axios = require('axios'); | |
const llamarApi = async (url,llamados = 0) => { | |
try { | |
const {data} = await axios.get(url); | |
console.log(data); | |
return data; | |
}catch (e) { | |
if (llamados > 5) { | |
return ''; | |
} | |
console.log(e) | |
return llamarApi(url, llamados +1) | |
} | |
} | |
llamarApi('https://jsonplaceholder.typicode.com/users'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment