Skip to content

Instantly share code, notes, and snippets.

@acgray
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acgray/f17a84e10ec236026a74 to your computer and use it in GitHub Desktop.
Save acgray/f17a84e10ec236026a74 to your computer and use it in GitHub Desktop.
http = require('http');
module['exports'] = function echoHttp (hook) {
var options = {
hostname: 'www.telize.com',
port: 80,
path: '/geoip/'+hook.params.ip,
method: 'GET'
}
http.get('http://www.telize.com/geoip/'+hook.params.ip, function(res) {
var body = '';
response.on('data', function(chunk) {
body += chunk;
});
res.on('end', function() {
hook.res.end(JSON.stringify({
ip: hook.params.ip,
geo: JSON.parse(body)
}));
})
}).on('error', function(e) {
hook.res.end(JSON.stringify({
error: e.message
}))
});
};
module['exports'].schema = {
"ip": {
"type": "string"
}
};
@Marak
Copy link

Marak commented Nov 17, 2014

response is not defined on line 14, it should be res.

@Marak
Copy link

Marak commented Nov 17, 2014

After reviewing the logs further it appears these errors weren't being sent back to the client, so you probably never saw the error. Errors are suppose to be sent back to the client so you can see them.

Opened up an issue at stackvana/hook.io#15

@Marak
Copy link

Marak commented Nov 19, 2014

Errors should now pipe back to the client.

Thanks for trying out the service!

Please let me know if you have any other issues getting your Hook running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment