Issuing a web service request using Node.js
So far, our server doesn't do much in response to a POST
request; all it does is say "OK" and return the client's JSON back to the client. Typically, your server will need to do something with the JSON you provide, that is, make a web or database query, for example, or perform a computation. Our example queries the web service JSON endpoint at http://www.aprs.fi/, which lets you see how you can make a server-to-server web service request using Node.js.
Getting ready
If you want to run the example for yourself, you'll first need to go to http://www.aprs.fi, register for an account, and obtain an API key. Follow the links on the page to do this, and substitute your API key for the text "—key-"
in the example that follows.
How to do it...
Our Node.js code will construct a URL with the identifier of the station we're interested in and our API key, and issue an additional HTTP request on behalf of the client...