你如何解决这个*?node.js requestify似乎什么都不做
对不起,但它是如此令人失望什么时候简单的东西不工作的方式,它声称他们应该。
以下是直接从projetc的gitHub网站截取。
如果我在PostMan中做同样的事情 - 没问题。
第一个console.log()工作。但是,以下的任何一个被调用。 看起来.then()s和.fail()会被调用。如果我添加一个catch()也不会被调用。
我确定在不同的node.js Express web应用程序中工作时没有问题。此应用程序是Express Web应用程序根目录中存在的node.js控制台应用程序(单个.js文件)。
这个.js文件在编译或执行时不会引发任何错误。
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());
})
;
您是否需要该模块? 'var requestify = require('requestify'); ' – Badacadabra
编译或运行时没有错误。如果我没有发生错误“'requestify'没有定义”。但是,是的。感谢您的询问。 – Steve
我测试了你的代码,它工作得很好。你在第一个'console.log'中只有一个错字。请使用双引号(“”)并再次测试。 – Badacadabra