Hi, I would like to get the price of database and add “$” in front of the price.
The price data type is number and the field name is “Price”.
The code are below:
import wixData from ‘wix-data’;
$w.onReady( function () {
let price_text = $w(“#dataset1”).getCurrentItemIndex().Price;
$w(‘text5’).text = “$” + price_text;
});
The log is
TypeError: Cannot ead propetty ‘Price’ of null
The problem is most likely that the dataset is not yet ready and therefore no item is returned. You should use the dataset onReady() function. Something like this:
import wixData from 'wix-data';
$w.onReady(function () {
$w("#dataset1").onReady( () => {
let price_text = $w("#dataset1").getCurrentItemIndex().price;
$w('#text5').text = "$" + price_text;
});
});
Also note the following:
Good luck,
Yisrael