老师,这个问题很多都有,是怎么解决的呢
来源:2-7 第二天 先撸一个自动回复出来
qq_smile笑看花_0
2016-06-22
{ _bitField: 136314880,
_fulfillmentHandler0: undefined,
_rejectionHandler0: undefined,
_progressHandler0: undefined,
_promise0: undefined,
_receiver0: undefined,
_settledValue:
[Error: Non-whitespace before first tag.
Line: 0
Column: 1
Char: []
}
Unhandled rejection Error: Non-whitespace before first tag.
Line: 0
Column: 1
Char: [
at error (/Users/mac/wechat/node_modules/xml2js/node_modules/sax/lib/sax.js:667:10)
at strictFail (/Users/mac/wechat/node_modules/xml2js/node_modules/sax/lib/sax.js:693:7)
at beginWhiteSpace (/Users/mac/wechat/node_modules/xml2js/node_modules/sax/lib/sax.js:967:7)
at Object.write (/Users/mac/wechat/node_modules/xml2js/node_modules/sax/lib/sax.js:1019:11)
at Parser.exports.Parser.Parser.parseString (/Users/mac/wechat/node_modules/xml2js/lib/xml2js.js:503:31)
at Parser.parseString (/Users/mac/wechat/node_modules/xml2js/lib/xml2js.js:7:59)
at Object.exports.parseString (/Users/mac/wechat/node_modules/xml2js/lib/xml2js.js:535:19)
at /Users/mac/wechat/wechat/util.js:69:16
at tryCatcher (/Users/mac/wechat/node_modules/bluebird/js/main/util.js:26:23)
at Promise._resolveFromResolver (/Users/mac/wechat/node_modules/bluebird/js/main/promise.js:480:31)
at new Promise (/Users/mac/wechat/node_modules/bluebird/js/main/promise.js:70:37)
at Object.exports.formatMessage (/Users/mac/wechat/wechat/util.js:68:12)
at Object.<anonymous> (/Users/mac/wechat/wechat/g.js:97:30)
at GeneratorFunctionPrototype.next (native)
at Object.<anonymous> (/Users/mac/wechat/node_modules/koa/node_modules/koa-compose/index.js:28:19)
at GeneratorFunctionPrototype.next (native)
4回答
-
Scott
2017-04-12
response.body 是正确的,按照这个来。
另外,把 node_modules 删掉后,重新安装一遍,来试试这个代码会不会打印上述错误了。如果还错误,把 g.js 和 wechat.js 代码贴出来看一下
00 -
Scott
2016-06-22
不要慌,代码都是调试出来的,先把调用 xml 之前时候数据打印出来,看推送过来的数据是不是正确的,然后一步一个 console,陆续往下走。
如果数据一路都正确,那么把 xml2js 的模块版本换一个稍微老一点的版本试试看
052017-04-12 -
verlet
2017-04-12
console.log(request({json: true,'url': url}).then( data=> {console.log('-------body------');console.log(data.body);})).查看文档发现只有body才是我们需要的{ access_token: '', expires_in: 7200 }得到这样的,应该这样写request({json: true,'url': url }).then(function(response) { console.log("---->" + response.body);let data = response.body;
00 -
qq_smile笑看花_0
提问者
2016-06-24
谢谢老师,解决了。模块没导出
022016-10-24
相似问题