Hi all ,
I am trying to get the array returned from the function . but i cannot get the return values from the function
// My Wix main code for calling Country detail public function
import {CountryDetail}from 'public/CountrySearch.js';
$w.onReady(function () {
var king=[];
console.log("ready");
king=CountryDetail("#selection1");
// i added this to catch the return values
console.log(king);
});
the public function
import wixData from 'wix-data';
export function CountryDetail(SelectionName)
{
var TotalCount;
wixData.query("CountryDetail")
.find()
.then((results) => {var test = [];
console.log("*****--------*****");
let item = results.items;
TotalCount = item.length;
console.log("item length", item.length);
for (let i = 0; i < TotalCount; i++) {
test[i] = {
label: item[i].name,
value: item[i].country_code.toString()
};
}
$w(SelectionName).options = test;
return(test);
// this is not throwing the values back to the calling statement;
});
}
anyone can help on this .
I am not sure where i am wrong . i want to use the return array in my geomap
Regards
jap