Skip to content
Node/JS helper library for the ReliefWeb API
JavaScript Makefile
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
config
lib
test
.gitignore
.travis.yml
Makefile
README.md Add bower badge to README.
bower.json
package.json Bump library version.

README.md

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);
    });
Something went wrong with that request. Please try again.