International Space Station
var myLocation = "San Francisco, CA";
var Promise = require('bluebird');
var moment = require('moment');
var _ = require('lodash');
var request = Promise.promisifyAll(require('request'));
var geocode = Promise.promisifyAll(require('notebook')('capicue/geocode/2.0.0'));
var issNowUrl = 'http://api.open-notify.org/iss-now.json';
var issPassUrl = 'http://api.open-notify.org/iss-pass.json';
var astrosUrl = 'http://api.open-notify.org/astros.json';
var body = await request.getAsync(issNowUrl);
console.log("Current ISS Position");
JSON.parse(body[1]).iss_position;
var location = await geocode.lookupAsync(myLocation);
var options = {lat: location.lat, lon: location.lng};
var result = await request.getAsync({url: issPassUrl, qs: options});
var timestamp = JSON.parse(result[1]).response[0].risetime;
var time = moment.unix(timestamp);
"The ISS will be above " + myLocation + " again " + time.fromNow();
var response = await request.getAsync(astrosUrl);
var data = JSON.parse(response[1]);
var people = _.map(data.people, function(person) { return person.name + " (" + person.craft + ")"; });
console.log("There are " + data.number + " people in space right now. ");
console.log("They are " + people.join(", ") + ".");
21 comments