xtian / node-armory

A simple node.js wrapper around Blizzard's REST API for World of Warcraft.
MIT License
24 stars 8 forks source link

Using a proxy, eg like Charles #3

Closed kimptoc closed 11 years ago

kimptoc commented 11 years ago

Hi,

I am getting some occasional internal server errors when I call the armory.

Is there a way to use a proxy like Charles to see the full response details?

Or is there a better way to view this, eg verbose on :)

I see that the request library used, https://github.com/mikeal/request, supports proxies.

I am thinking to give node-armory a way of passing through http options, perhaps as an extra option.

Thanks, Chris

PS A sample way of doing this is in this fork: https://github.com/kimptoc/node-armory

No tests added :( - could do something like use sinon to mock a proxy server and test via that...

xtian commented 11 years ago

Hm, so it seems like the real issue is that you want access to the full response object as opposed to just the body, right?

The easiest way to solve that would be to pass it as the third parameter of the callback. Does that sound ok?

kimptoc commented 11 years ago

Hi,

Not really after the full response in my app - more for debugging, to see what I am getting from Armory, hence using Charles.

kimptoc commented 11 years ago

Hi,

When using a proxy and there are network issues, Charles gives an HTML error, which causes the JSON.parse call to blow up.

I have wrapped that in a try/catch in this patch, if you're interested:

https://github.com/kimptoc/node-armory/commit/61742d6a04d01a7a56208c72ea782631cadc772a

Regards, Chris

xtian commented 11 years ago

Fixed by 83a6e08a2b56301e292c55c22fc039b380ddb1bb.

kimptoc commented 11 years ago

Cheers.