Created
July 29, 2018 10:12
-
-
Save a-eid/1eeef963d2a1dd5538850a319b52a9c3 to your computer and use it in GitHub Desktop.
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
const fetch = require("isomorphic-fetch") | |
const endpoint = `https://talaikis.com/api/quotes/random/` | |
function* createGetQuote(){ | |
const resp = yield fetch(endpoint) | |
const quote = yield resp.json() | |
return `${quote.quote}--${quote.author}` | |
} | |
const getQuote = createGetQuote() | |
getQuote.next().value.then( | |
res => getQuote.next(res).value | |
).then( | |
res => getQuote.next(res).value | |
).then(console.log) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment