Doing this way → NO PROBLEM! Everything works!
function zzz(skipValue, limitValue) {
wixData.query("DATABASE")
.skip(skipValue)
.limit(limitValue)
.find()
.then((res)=>{let items = res.items;
console.log("ITEMS: ", items);
$w('#rep3').data = items;
});
}
Trying to do this way → FAILS! What am i missing ???
let limitValue = 10;
let skipValue = 20;
let data = await get_AllProductsData(limitValue, skipValue);
async function get_AllProductsData(limitValue, skipValue) {
let query = await wixData.query("DATABASE");
if(limitValue) {query.limit(limitValue);}
if(skipValue) {query.skip(skipValue);}
return query.find()
.then(async(res)=>{//console.log("RES-PRODUCTS: ", res);
if (res.items.length > 0) {console.log("Data found!");
let items = res.items; //console.log("ITEMS: ", items);
return (items);
}
else {console.log("No data found!"); return ([]);}
}).catch((err)=>{console.log(err); return [];});
}
Also tried the following…
let limitValue = 10;
let skipValue = 20;
let data = await get_AllProductsData(limitValue, skipValue);
async function get_AllProductsData(limitValue, skipValue) {
let query = await wixData.query("DATABASE");
if(limitValue) {await query.limit(limitValue);}
if(skipValue) {await query.skip(skipValue);}
return query.find()
.then(async(res)=>{//console.log("RES-PRODUCTS: ", res);
if (res.items.length > 0) {console.log("Data found!");
let items = res.items; //console.log("ITEMS: ", items);
return (items);
}
else {console.log("No data found!"); return ([]);}
}).catch((err)=>{console.log(err); return [];});
}
…and also tried this one …
let limitValue = 10;
let skipValue = 20;
let data = await get_AllProductsData(limitValue, skipValue);
async function get_AllProductsData(limitValue, skipValue) {
let query = await wixData.query("DATABASE");
if(limitValue) {return query.limit(limitValue);}
if(skipValue) {return query.skip(skipValue);}
return query.find()
.then(async(res)=>{//console.log("RES-PRODUCTS: ", res);
if (res.items.length > 0) {console.log("Data found!");
let items = res.items; //console.log("ITEMS: ", items);
return (items);
}
else {console.log("No data found!"); return ([]);}
}).catch((err)=>{console.log(err); return [];});
}
Can not find the right key for this issue