newenthusiast newenthusiast - 1 year ago 97
Javascript Question

How to send query from nodejs server to open data server?

I'm working with open data:

The open data site allows to query the data, and example query is below:$where=magnitude > 3.0
However, this, I imagine is URL querying. If I had to get the same object on my nodejs server, how would I format the query to receive the json objects on the node server?

Are there any security threats or exposing threats to querying for data this way?

Answer Source

Probably the easiest way to do this is via request package. You could do something like the following:

var request = require('request');

request('$where=magnitude%3E3.0', function (err, res, body) {
  if (err) {
    //handle error
  } else {
    console.log(body); // and do stuff with your results

If you run this, you'll see a print out of your result array. There aren't really any security threats with this. Your just doing a GET request from an open data source. Pretty standard stuff. Same kind of transactions happen everyday all over the web.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download