简体   繁体   English

在Bluemix中使用NodeJS将对象上传到Cloudant

[英]Uploading objects to Cloudant using NodeJS in Bluemix

I'm trying to save the JSON from the GET request to an object and then upload the object to the Cloudant DB Anyone know what I'm doing wrong? 我正在尝试将GET请求中的JSON保存到一个对象,然后将该对象上传到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');
});

You have a male formatted URL for the request. 您有一个男性格式的请求网址。 And the code for inserting in cloudant data base is wrong written: 而且用于插入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
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM