Saturday 15 April 2017

node.js requestify appears to do nothing at all

How do you troubleshoot this *?

I'm sorry but it is SO disappointing when what should be simple things don't work the way it is claimed that they should.

Following is clipped directly from the projetc's gitHub site.

And if I do the same thing in PostMan - no problem.

The first console.log() works. But NONE of the following get called. It appears the the .then()s nor the .fail()s get called. And if I add a catch() that too isn't called.

I DO have requestify working in different node.js Express web applications without issue. This application is a node.js console application (a single .js file) which exists in the root of the Express web app.

This .js file doesn't throw any errors when compiled or executed.

console.log('Let's begin');

/* appears to  do nothing */
requestify.get('https://www.example.com/api/get.json')
.then(function (response) {
    console.log('response', response.getBody());
})
.fail(function (response) {
        console.log('response Error', response.getCode());
    })
;


/* also appears to do nothing */
requestify.request('https://www.example.com/api/get.json', {
    method: 'GET'
})
.then(function(response) {
    console.log('responsebody', response.getBody());
    console.log('response headers',response.getHeaders());
    console.log('responseheader Accept', response.getHeader('Accept'));
    console.log('response code', response.getCode());
    console.log('responsebody RAW', response.body);
    })
.fail(function (response) {
        console.log('response Error', response.getCode());
    })
;



via user2367083

No comments:

Post a Comment