Skip to content

Instantly share code, notes, and snippets.

@0x14Rp
Last active July 17, 2020 19:06
Show Gist options
  • Save 0x14Rp/0a6f7a8fce13f76811ff22353043e59e to your computer and use it in GitHub Desktop.
Save 0x14Rp/0a6f7a8fce13f76811ff22353043e59e to your computer and use it in GitHub Desktop.
example for recursive function πŸ˜‰
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