如何对此进行故障排除*
我很抱歉,但当本应简单的事情并没有按照声称的方式工作时,这是非常令人失望的。
下面是直接从projetc的gitHub站点上截取的内容。
如果我在PostMan中做同样的事情--没问题。
第一个console.log()起作用了。但是下面的代码都不会被调用。似乎调用了.then()或.fail()。如果我添加了catch(),也不会调用它。
我确实在不同的node.js快速web应用程序中使用requestify,没有问题。此应用程序是一个node.js控制台应用程序(单个.js文件),它存在于Express web应用程序的根目录中。
此.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());
})
;发布于 2017-04-15 21:50:53
两件事,
'use strict';
const requestify = require('requestify');
/* 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());
})
;
发布于 2017-04-15 22:22:45
我不能确切地说它是什么,但requestify不是一个控制台应用程序。但正在进行第一次尝试,已经迁移到webapp应用程序。
https://stackoverflow.com/questions/43426711
复制相似问题