0.4.3 • Published 9 years ago

reliefweb v0.4.3

Weekly downloads
6
License
MIT
Repository
github
Last release
9 years ago

reliefweb.js

JavaScript and Node bindings for the ReliefWeb API. Read the docs on ReliefWeb.int or get started with the API.

Build Status npm version Bower version

Installation

Install via NPM

Checkout this repository and run:

npm install

Include in your code with

var reliefweb = require("reliefweb");

Manual installation

Download the latest code from GitHub, and include lib/reliefweb.js in your html.

<script type="text/javascript" src="node_modules/superagent/superagent.js"></script>
<script type="text/javascript" src="lib/reliefweb.js"></script>

Usage

Node.js

var reliefweb = require('reliefweb');
var rw = reliefweb.client();

rw.reports(1414, function(err, response) {
  console.log(response.body);
});

Browser <script>

<script type="text/javascript">
    var rw = reliefweb.client();

    rw.reports(1414, function(err, response) {
        console.log(response.body);
    });
</script>

Running Tests

  • Install all dev dependencies.
  • Use make test or make jenkins
  • To specify configuration for the tests, such as the host, we are using the node-config library. ** For example, export NODE_CONFIG='{"api":{"host":"api.rwlabs.org"}}'

Tips & Tricks

Get the full URL in the response callback

    rw.reports().end(function(err, response) {
      var request = response.request;
      console.log(request.url);
    });