Skip to content

Instantly share code, notes, and snippets.

@a-eid
Created July 29, 2018 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a-eid/1eeef963d2a1dd5538850a319b52a9c3 to your computer and use it in GitHub Desktop.
Save a-eid/1eeef963d2a1dd5538850a319b52a9c3 to your computer and use it in GitHub Desktop.
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