chovy
chovy

Reputation: 75656

api call fails with request module in node.js app

The following API call fails for me when I try it in my app. It works fine from same machine in the browser. I should get a JSON response.

var url = 'http://www.btc38.com/trade/getTradeList.php?coinname=BTC';

request.get({ url: url, json: json, strictSSL: false, headers: { 'User-Agent' : '' } }, function (err, resp, data) {
});

edit: by "fails" i mean i get a non-json error page.

Upvotes: 0

Views: 109

Answers (1)

robertklep
robertklep

Reputation: 203231

You can't use an empty User-Agent header, otherwise the request fails.

So use something like:

'User-Agent' : 'request/x.y'

Upvotes: 1

Related Questions