Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. function getCharacterWithCallback(id, callback) {
  2. const CHARACTER_URL = `${API_URL}${PEOPLE_URL.replace(':id', id)}`
  3.  
  4. fetch(`${CHARACTER_URL}`)
  5. .then(function (response) {
  6.  
  7. return response.json();
  8. })
  9. .then(function (jsonResponse) {
  10. if(callback){
  11. callback()
  12. }
  13. console.log(`Hola, yo soy ${jsonResponse.name}`);
  14. })
  15. .catch((error) => {
  16. console.log('ha ocurrido un error')
  17. })
  18.  
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement