簡體   English   中英

在Bluemix中使用NodeJS將對象上傳到Cloudant

[英]Uploading objects to Cloudant using NodeJS in Bluemix

我正在嘗試將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');
});

您有一個男性格式的請求網址。 而且用於插入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