Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getCharacterWithCallback(id, callback) {
- const CHARACTER_URL = `${API_URL}${PEOPLE_URL.replace(':id', id)}`
- fetch(`${CHARACTER_URL}`)
- .then(function (response) {
- return response.json();
- })
- .then(function (jsonResponse) {
- if(callback){
- callback()
- }
- console.log(`Hola, yo soy ${jsonResponse.name}`);
- })
- .catch((error) => {
- console.log('ha ocurrido un error')
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement