【发布时间】:2016-09-11 09:40:27
【问题描述】:
$.getJSON('https://api.twitch.tv/kraken/channels/' + SLoppierKitty7, function(channel) {
if (channel["stream"] == null) {
var live ="no"
} else {
var live ="yes"
}
这是我的代码,但是当我运行它时,我收到以下错误
E:\Sloppers bot\node_modules\jQuery\lib\node-jquery.js:5 window = require('jsdom').jsdom().createWindow(); ^
TypeError: require(...).jsdom(...).createWindow 不是函数 在创建时(E:\Sloppers bot\node_modules\jQuery\lib\node-jquery.js:5:39) 在 E:\Sloppers bot\node_modules\jQuery\lib\node-jquery.js:9435:18 在对象。 (E:\Sloppers bot\node_modules\jQuery\lib\node-jquery.js:9437:2) 在 Module._compile (module.js:434:26) 在 Object.Module._extensions..js (module.js:452:10) 在 Module.load (module.js:355:32) 在 Function.Module._load (module.js:310:12) 在 Module.require (module.js:365:17) 在需要(module.js:384:17) 在对象。 (E:\Sloppers bot\bot.js:2:9)
我该怎么办
这是给我正在工作的机器人
【问题讨论】:
-
nodejs中为什么要使用jquery请求json数据有什么原因吗?
-
除非您需要 $.getJSON 以外的 jquery,否则我建议使用 npmjs.com/package/request,它是 Node 原生 HTTP 模块的更简单包装器。
标签: javascript json node.js twitch