Last active
August 29, 2015 14:21
-
-
Save sergiodxa/122117a923f27a2a511d to your computer and use it in GitHub Desktop.
Generadores
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
import xhr from 'promised-xhr'; | |
function* obtenerDatos () { | |
try { | |
const data = yield xhr.get('/api/resource'); | |
const data2 = yield xhr.get(data.url); | |
return `${data2}!`; | |
} catch (error) { | |
throw error; | |
} | |
} | |
let iterador = obtenerDatos(); | |
iterador.next().value | |
.then(data => iterador.next(data.body).value) | |
.then(data => iterador.next(data.body).value) | |
.then(data => console.log(data)) | |
.catch(err => console.log(err)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment