-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclase30.js
31 lines (27 loc) · 806 Bytes
/
clase30.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const API_URL = 'https://swapi.dev/api/'
const PEOPLE_URL = 'people/:id'
const opts = { crossDomain: true }
function obtenerPersonaje(id, callback) {
const url = `${API_URL}${PEOPLE_URL.replace(':id', id)}`
// El ultimo argumento se cambia a funcion anonima para diferenciarla del callback
// Pero no cambia en nada la funcionalidad
$.get(url, opts, function (persona) {
console.log(`Hola, yo soy ${persona.name}`)
if (callback) {
callback()
}
})
}
obtenerPersonaje(1, function () {
obtenerPersonaje(2, function () {
obtenerPersonaje(3, function () {
obtenerPersonaje(4, function () {
obtenerPersonaje(5, function () {
obtenerPersonaje(6, function () {
obtenerPersonaje(7)
})
})
})
})
})
})