Javascript 输出承诺对象而不是结果时的jQuery
我想得到数据库中每个数据库的计数。当我尝试将其包装在jQuery承诺中时,当它完成时,它会将承诺对象而不是结果发送到then() 控制台输出如下。 请让我知道如何获得每个对象的响应Javascript 输出承诺对象而不是结果时的jQuery,javascript,jquery,promise,pouchdb,Javascript,Jquery,Promise,Pouchdb,我想得到数据库中每个数据库的计数。当我尝试将其包装在jQuery承诺中时,当它完成时,它会将承诺对象而不是结果发送到then() 控制台输出如下。 请让我知道如何获得每个对象的响应 谢谢。使用Promise.all()。jQuery延迟对象不一定处理与本机Promise方法相同的Promise对象。jQuery延迟对象不一定处理Promise对象,与本机Promise方法相同您可以使用Promise.all()来处理多个Promise,一次,请查看 您可以使用Promise.all()来处理多
谢谢。使用
Promise.all()
。jQuery延迟对象不一定处理与本机Promise
方法相同的Promise
对象。jQuery延迟对象不一定处理Promise
对象,与本机Promise
方法相同您可以使用Promise.all()
来处理多个Promise,一次,请查看
您可以使用
Promise.all()
来处理多个承诺,一次,请查看
Promise.all()
-函数pookdb#info
是否返回jQuery承诺?Promise.all()
-函数pookdb#info
是否返回jQuery承诺?您缺少了一些重要的()
您缺少了一些重要的()
function validateAppData(event) {
var db1 = new PouchDB( "distributors" );
var db2 = new PouchDB( "categories" );
var db3 = new PouchDB( "genericTypes" );
var db4 = new PouchDB( "products" );
$.when(
db1.info(),
db2.info(),
db3.info(),
db4.info()
).then( function( distributors, categories, genericTypes, products ) {
console.log(distributors);
console.log(categories);
console.log(genericTypes);
console.log(products);
console.log("all done")
console.log(distributors.doc_count);
} );
}
var db1 = new PouchDB("distributors");
var db2 = new PouchDB("categories");
var db3 = new PouchDB("genericTypes");
var db4 = new PouchDB("products");
Promise.all([
db1.info(),
db2.info(),
db3.info(),
db4.info()
]).then(([ distributors, categories, genericTypes, products ]) => {
console.log(distributors);
console.log(categories);
console.log(genericTypes);
console.log(products);
console.log("all done");
console.log(distributors.doc_count);
});