src/index.js
function astroViewer (options, cb) {
  request({
    url: 'http://astroviewer-sat2c.appspot.com/predictor',
    qs: {
      var: 'passesData',
      lat: options.lat,
      lon: options.lon,
      name: options.name
    },
    headers: {
      'User-Agent': 'request'
    }
  }, function (error, response, body) {
    if (error) {
      cb(error)
    }
    // Trim the javascript response
    var raw = body.slice(17).slice(0, -2)
    // make sure the keys have quotes around them
    raw = raw.replace(/(['"])?([a-zA-Z0-9_]+)(['"])?:/g, '"$2":')
    // turn the result into valid JSON (hopefully)
    var info = JSON.parse(raw)
    cb(false, info)
  })
}
function astroViewer (options, cb) {
  request({
    url: 'http://astroviewer-sat2c.appspot.com/predictor',
    qs: {
      var: 'passesData',
      lat: options.lat,
      lon: options.lon,
      name: options.name
    },
    headers: {
      'User-Agent': 'request'
    }
  }, function (error, response, body) {
    if (error) {
      cb(error)
    }
    // Trim the javascript response
    var raw = body.slice(17).slice(0, -2)
    // make sure the keys have quotes around them
    raw = raw.replace(/(['"])?([a-zA-Z0-9_]+)(['"])?:/g, '"$2":')
    // turn the result into valid JSON (hopefully)
    var info = JSON.parse(raw)
    cb(false, info)
  })
}
function astroViewer ( options , cb ) { request ( { url : 'http://astroviewer-sat2c.appspot.com/predictor' , qs : { var : 'passesData' , lat : options . lat , lon : options . lon , name : options . name } , headers : { 'User-Agent' : 'request' } } , function ( error , response , body ) { if ( error ) { cb ( error ) } // Trim the javascript response var raw = body . slice ( 17 ) . slice ( 0 , - 2 ) // make sure the keys have quotes around them raw = raw . replace ( / (['"])?([a-zA-Z0-9_]+)(['"])?: / g , '"$2":' ) // turn the result into valid JSON (hopefully) var info = JSON . parse ( raw ) cb ( false , info ) } ) }
Query astroviewer and dangerously turn the javascript into parsable JSON.
@param  {object}   options An object containing the latitude, longitude and location name
@param  {Function} cb
Query astroviewer and dangerously turn the javascript into parsable JSON .