Skip to content

Instantly share code, notes, and snippets.

@markselby
Created August 19, 2014 17:10
Show Gist options
  • Save markselby/57409d514ff4bccd9f30 to your computer and use it in GitHub Desktop.
Save markselby/57409d514ff4bccd9f30 to your computer and use it in GitHub Desktop.
JSON API proxy debugger
// Don't forget to npm install hoxy
var hoxy = require('hoxy');
var proxy = new hoxy.Proxy().listen(8080);
proxy.intercept({
phase: 'request',
}, function(req, resp) {
console.log('\n\n==============================================');
console.log('Request: ' + req.fullUrl());
Object.keys(req.headers).forEach(function(header) {
console.log(' ', header, ':', req.headers[header]);
});
});
proxy.intercept({
phase: 'response',
mimeType: 'application/json',
as: 'json'
}, function(req, resp) {
console.log('\nResponse :', resp.statusCode);
Object.keys(resp.headers).forEach(function(header) {
console.log(' ', header, ':', resp.headers[header]);
});
console.log(JSON.stringify(resp.json, null, 2));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment