$.getJSON('https://api.twitch.tv/kraken/channels/' + SLoppierKitty7, function(channel) {
if (channel["stream"] == null) {
var live ="no"
} else {
var live ="yes"
}
这是我的代码,但是当我运行它,我得到以下错误的jQuery的NodeJS需要jsdom
E:\Sloppers bot\node_modules\jQuery\lib\node-jquery.js:5 window = require('jsdom').jsdom().createWindow(); ^
TypeError: require(...).jsdom(...).createWindow is not a function at create (E:\Sloppers bot\node_modules\jQuery\lib\node-jquery.js:5:39) at E:\Sloppers bot\node_modules\jQuery\lib\node-jquery.js:9435:18 at Object. (E:\Sloppers bot\node_modules\jQuery\lib\node-jquery.js:9437:2) at Module._compile (module.js:434:26) at Object.Module._extensions..js (module.js:452:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Module.require (module.js:365:17) at require (module.js:384:17) at Object. (E:\Sloppers bot\bot.js:2:9)
我该怎么办
这是一个BOT我的工作
是否有理由为什么要使用jQuery来请求nodejs中的json数据? –
除非您需要超过$ .getJSON的jquery,否则我会建议使用https://www.npmjs.com/package/request,它是Node本地HTTP模块的更简单的包装。 – tmslnz