Hello! I am trying to access a specific field of a dataset. I’ve searched a lot and all the examples that I’ve found use the whole array of objects. They never access a specific field of a specific object. For example:
$w("#myDataset").getItems(3, 2)
.then( (result) => {
let items = result.items;
let totalCount = result.totalCount;
let offset = result.offset;
} )
.catch( (err) => {
let errMsg = err.message;
let errCode = err.code;
} );
I know that this code, taken from the Wix API page, gets 2 items, beggining at the index 3, and puts them in the “items” array, but let’s say that there’s a text field called “Name” for every item in my database. How could I access the “Name” field of the second item retrieved by this method that I just used above ?
I am assuming ‘name’ here is the Field Key or can we use the Field Name?
I have a Field Key that contains a space - Recipe Name, how would I access that specific field in that case? I get unexpected token errors on my .js file when I use either of the below:
Hi,
The Field Name is just a label. If you wish to get a specific item, you should use the Field Key. I recommend checking out the video tutorial and the explanation here .