Skip to content

Instantly share code, notes, and snippets.

@a-eid a-eid/gen.js
Created Jul 29, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.