Hi,
Its not working , I think my code is not totally right, pls help
this is my code
import wixData from ‘wix-data’;
export function button34_click(event, $w) {
if ($w(" #dynamicDataset ").getCurrentItem()) {
wixData.remove(“Profile”, “itemId”)
.then( (results) => {
let item = results; //see item below
} )
.catch( (err) => {
let errorMsg = err;
} );
}
}
this is the error when i run in preview
DatasetError: Operation (getCurrentItem) not allowed on an unconfigured datasetremove operation failed: DatasetError: The dataset didn’t load yet. You need to call remove inside the onReady for the dataset.
You aren’t getting the current item correctly. For information, read wix-dataset.getCurrentItem() . Also, on a page load the dataset might not be available so you might need to use wix-dataset.onReady() .
It’s also really worth watching the Working with Datasets in 5 Steps video tutorial.
Good luck,
Yisrael
@yisrael-wix Youtube says the video you recommended isn’t available/ is set to private.
Cheers,
Harry
The video can’t be viewed anymore as it has been set to private even if you do log yourself in.
Therefore you should be reading the Wix API Reference links that Yisrael had previously posted.
https://www.wix.com/corvid/reference/wix-dataset.Dataset.html#getCurrentItem
https://www.wix.com/corvid/reference/wix-dataset.Dataset.html#onReady
Just note that getCurrentItem will get all the info for that current item, if you are wanting to just get a specific field then you need to be using the field key at the end of your code like this.
getCurrentItem().fieldkeyhere;
This post is two years old now, if you need anymore help then please add a new post to the forum.
CLOSED.