Open jimdebeer opened 7 years ago
check marcus his request-generator package
const url = 'http://api.themoviedb.org' const apikey = '&api_key=7049bfd41c073cdc48a026969d0cb3e1' const request = require('request-generator') const s = require('./') var page = 1 const a = s(request( `${url}/3/discover/movie?sort_by=popularity.desc&page=${page}${apikey}`, 'results.*', data => ({ [data.id]: data }), (err, cnt, req) => new Promise(resolve => { if (err) { console.log('err time', err) } req.path = `/3/discover/movie?sort_by=popularity.desc&page=${++page}${apikey}` setTimeout(() => resolve(), 1000) }) )) a.on((val) => { console.log(val && val.title) }) console.log('---')
so as tasks you could use generator functions, that get re-invoked, simple api for multiple steps etc
check marcus his request-generator package