0

I've tried to call stackexchange api from client side using the below code, It is working fine

HTTP.call("GET",questionsURL,{params:{site:"stackoverflow",key:key,function(e,res)
       {
          if(e)
          {
             console.log("error"+e);
          }
          else
          {
           //logic
          }
        });

When I tried call the same function from server side it is returnig something I tried to log it and it is showing the following result

error

The server side code is

var futt=new Future();
          HTTP.call("GET", userDetailsURL,{params:{site:"stackoverflow",key:key}},function(error,result)
          {
                futt.return(result);
                console.log(result));
           }); 
           return futt.wait();

What is the issue here?Any one help me pls

1 Answers1

1

It looks like the issue is the stream by the api is gzip encoded. (Also documented here: http://api.stackexchange.com/docs/compression)

There isn't a way to get passed this, unless you decompress the data yourself.

It might be worth looking into into an npm module that does this all for you like those listed at: https://www.npmjs.org/search?q=stackexchange

It doesn't look like they allow uncompressed requests & Meteor gzip decode results

Tarang
  • 75,157
  • 39
  • 215
  • 276
  • But why is it returning the unzipped result when we call it from client side – user3716227 Jul 08 '14 at 12:52
  • @user3716227 Your web browser is able to parse gzip'd data. The server side `HTTP` doesn't know what gzip is. If you want you can fork the http package to add this functionality in, but it is very tedious. – Tarang Jul 08 '14 at 13:16