Last active
August 29, 2015 14:09
-
-
Save acgray/f17a84e10ec236026a74 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
} | |
}; | |
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
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
response
is not defined on line 14, it should beres
.