actually I am tring to write a module that, given an ID and a request rate, returns a readable stream which emits location data for the corresponding satellite. (http://wheretheiss.at/w/developer for data)..... I am able to get my api call...... but not sure how to pass the ID and a request rate updated my code but still errors.. providing my code below...
http://runnable.com/VCnTUf_093weD3qx/readable-updated-for-node-js-and-hello-world
var request = require('request');
var readable = request({
method: 'GET',
rejectUnauthorized: false,
uri: 'https://api.wheretheiss.at/v1/satellites/25544'
})
/*readable.on('readable', function() {
// there is some data to read now
})*/
var readable = createStream('some-id', 100000)
readable.on('data', function(data) {
console.log('data', data);
})
**function createStream (id, rate) {
var stream = through(function(data) {
this.queue(data)
})
setInterval(function() {
getInfo(id, function(err, data) {
stream.write(data)
})
}, rate)
return stream
}**
readable.on('data', function(chunk) {
console.log('got %d bytes of data', chunk.length);
})
readable.on('end', function() {
console.log('there will be no more data.');
});