Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Drobiazko committed Oct 21, 2014
1 parent e8b974c commit 63bb328
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# HttpComponent example
# The most simple HttpComponent example

````js
var api = require('elasticio-node-api');
Expand All @@ -14,7 +14,34 @@ function doProcess(msg, cfg) {
json: true
};

new HttpComponent(this).get(options);
}
````

# Overriding the success handler

````js
var api = require('elasticio-node-api');
var HttpComponent = api.HttpComponent;
var messages = api.messages;

exports.process = doProcess;

function doProcess(msg, cfg) {

var self = this;

var options = {
url: 'http://foobarbazbarney.com/api',
json: true
};

function onSuccess(response, body) {

if (response.statusCode !== 201) {
throw new Error(JSON.stringify(body));
}

return messages.newMessageWithBody(body);
}

Expand Down

0 comments on commit 63bb328

Please sign in to comment.