The Stackoverflow API compresses its JSON output using gzip or deflate: http://api.stackexchange.com/docs/compression
Is there anyway within node-RED or in a function where I can do this without having to follow the instruction in the following link? http://international.github.io/2016/04/14/08-07-decompressing_gzip_http_response_with_node-red
I am able to get the response from the Stackoverflow API by using the work around above. It seems that since a normal browser can easily decompress the response that node-RED should be able to without having to change the settings.js file.
The tried using the parsed JSON response return selection for a web request, but it comes back as failed to parse.
It is not possible to do this without modifying your settings file as it needs to require a library (zlib
) that isn't part of the sandbox the Function node uses.
We can look at adding a compression middleware into our default stack - but we need to be careful to not cause changes in behaviour to what flows expect today.
An alternative to explore is whether you are able to set suitable headers as part of your http request to ask the server to not compress the response. I've use that approach before with some APIs, but also found others that don't pay attention to such requests.