0
私は、次のコードを持っている:updateDocument()
はdb.insertが提供する結果を返すために、私は希望Cloudantの挿入ステータスを返すにはどうすればよいですか?
updateDocument = (data) => {
Cloudant(CONN_STRING, (err, cloudant) => {
if (err) {
throw new Error('Failed to initialize Cloudant: ' + err.message);
}
let db = cloudant.db.use('my-db')
db.insert(data, (err, result) => {
if (err) {
throw new Error('Failed to initialize Cloudant: ' + err.message);
}
else {
console.log(result);
}
})
});
}
を。しかし、変数を返そうとすると、定義されません(私は非同期呼び出しのため信じています)。 async
とawait
を試しましたが、うまく動作しなかったため、正しく設定していない可能性があります。
ありがとうございました!