Request to API hangs with Restify

552 Views Asked by At

I'm trying to request some information from an HTTPS API using Restify. The following works fine:

curl 'https://api.mercadolibre.com/sites/MLA/search?q=cartera&seller_id=156853713&limit=10&offset=0'

However, this hangs:

var client = restify.createClient({
   url: "https://api.mercadolibre.com"
});

search = function(response, name, store_id, limit, offset) {
    client.get("/sites/MLA/search?q=cartera&seller_id=156853713&limit=10&offset=0", function (err, req) {
    assert.ifError(err); // connection error
    var str = ''

    req.on('result', function (err, v_res) {
        assert.ifError(err); // HTTP status code >= 400

        v_res.on('data', function (chunk) {
            str += chunk;
        });

        v_res.on('end', function () {
            response.send(str)
        });
    });
});

}

with the following error: ECONNRESET. Googling around I found this post: Node.js Https request Error but the answer does not seem to work for me.

Any ideas? Thanks

0

There are 0 best solutions below