diff --git a/README.md b/README.md index e4cf66d..498c568 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# HttpComponent example +# The most simple HttpComponent example ````js var api = require('elasticio-node-api'); @@ -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); }