@russian-dima technically no, I just have a habit of adding that since it automatically adds it when creating event handlers :P.
Thanks for responding, I tried out your code and I got the same thing I did with the code above: I got the JSON list of items but when the res and items were commented, I got NULL.
The wixData.get() gives me a JSON formatted like this:
My base question is: How could I access these elements? Within the Promise I could do result[“title”] to give me the value of the title, but I can’t seem to access this outside of the Promise Scope, and also if I did:
function GetData(collection, itemid)
{
wixData.get(collection, itemid)
.then( (results) => {
let item = results;
//inside of scope:
console.log(item); //shows nothing.
console.log(results); //returns the Data I want.
console.log(item["title"]); //Returns What I want
console.log(results["title"]); //Returns What I Want.
var tit = "title";
console.log(item[tit]); //Returns What I Want.
console.log(results[tit]); //Returns What I Want. .
return (item); //returns the Data I want.
} )
}
//Outside of Scope:
console.log("A " + GetData("MyCollection", itemid)); //Returns What I Want. .
console.log("A " + GetData("MyCollection", itemid)["title"]); //I cannot access "title" outside of function/Promise Scope.
Getting the List of data is useless if I don’t know how to access the data in it outside the Promise. ![]()
