我尝试将JSON从GET请求保存到对象,然后将对象上传到Cloudant DB 谁知道我做错了什么?
var request = require("request");
var EventEmitter = require("events").EventEmitter;
var body = new EventEmitter();
var sample = cloudant.db.use('sample')
request("http://ieeexplore.ieee.org/gateway/ipsSearch.jsp?cs=IBM&hc=1000&rs=1001", function(error, response, data) {
body.data = data;
body.emit('update');
sample.insert({ crazy: true }, body.data, function(err, body, header{
// hmm
});
console.log('hmm');
});
答案 0 :(得分:0)
您有请求的男性格式化网址。插入cloudant数据库的代码写错了:
var request = require("request");
var EventEmitter = require("events").EventEmitter;
var body = new EventEmitter();
var sample = cloudant.db.use('sample')
request("http://ieeexplore.ieee.org/gateway/ipsSearch.jsp?cs=IBM&hc=1000&rs=1001", function(error, response, data) {
body.data = data;
body.emit('update');
//implement code for inserting in cloudant db for homework
});