I get this message when I load my website:
https://www.garimd.com/
and pressing F12:
Uncaught TypeError: Cannot read property 'dataset' of null
Can anyone help me understand what this means, what is the problem and how can I fix it?
I get this message when I load my website:
https://www.garimd.com/
and pressing F12:
Uncaught TypeError: Cannot read property 'dataset' of null
Can anyone help me understand what this means, what is the problem and how can I fix it?
Is it related to a Promise or something similar?
Post your code
Hi J.D. , if you remember this is a follow-up question from a few days before.
This happens only sometimes and I can’t figure when.
Anyway - this is my code:
import wixUsers from 'wix-users';
import wixData from 'wix-data';
import {session} from 'wix-storage';
import wixLocation from 'wix-location';
import {showFilteredResults} from 'public/filterNewResults.js'
$w.onReady(function () {
const CurrentCity = $w('#dropdownFilterCity').value;
// check if user has a pricing Plan
let user = wixUsers.currentUser;
let planName;
let userPlan;
user.getPricingPlans()
.then((pricingPlans) => {
userPlan = pricingPlans[0];
planName = userPlan.name;
if (planName === undefined) {
showFilteredResults(CurrentCity, false);
}
else if (planName === "Premium"){
$w("#textConnectedAsPremium").show();
$w("#dataset1").setFilter(wixData.filter()
.eq("isApproved", true)); // show only approved data
}
})
.catch(error => { // unknown user
showFilteredResults(CurrentCity, false);
console.log("unknown user error: " + error);
});
// show all cities in City-dropdown
wixData.query('oppositeSearch')
.ascending("city")
.eq("isApproved", true)
.find()
.then (res => {
let options = [{"value":'', 'label': 'כל הארץ'}];
const uniqueCities = getUniqueCities(res.items);
$w("#dropdownFilterCity").options = options.concat((buildOptions(uniqueCities)));
})
// actions for repeater's single item
$w("#repeater1").onItemReady(($item, itemData, inx) => {
// show a specific container's phone number
$item("#buttonContact").onClick(event => {
$item("#textPhoneNumber").show();
$item("#imageWhatsAppGreen").show();
$item("#imagePhone").show();
})
// create whatsapp url for each item
let whatsAppURL = "https://api.whatsapp.com/send/?phone=972"
+ itemData.phoneNumber.replace("-", "")
+ "&text=היי, ראיתי את המודעה שלך באתר גרים ודרים ויש לי מה להציע לך. זה עדיין רלוונטי?";
$item("#imageWhatsAppGreen").link = whatsAppURL;
$item("#imageWhatsAppGreen").target = "_blank";
// create a phone number to call, for each item
let phoneCall = $item("#imagePhone").link = "tel:+972-" + itemData.phoneNumber;
// show relevant icons for each item
if(!itemData.furniture) {
$item("#lineFurniture").show();
}
if(!itemData.animals) {
$item("#lineAnimals").show();
}
if(!itemData.yard) {
$item("#lineYard").show();
}
});
// delete outdated data
get_deleteEventsDatabaseOldData();
});
// delete outdated posts from dataset
export async function get_deleteEventsDatabaseOldData() {
let itemsToDelete;
let oneMonthAgoDate = new Date(
new Date().getFullYear(),
new Date().getMonth() - 2, // Add the month here (Change)
new Date().getDate()
);
let returnoptions = {
"headers": {
"Content-Type": "application/json"
}
};
let options = {
"suppressAuth": true,
"suppressHooks": true
};
return await wixData.query('oppositeSearch')
.lt("_updatedDate", oneMonthAgoDate)
.find(options)
.then((results) => {
if (results.items.length > 0) {
itemsToDelete = results.items;
for (let i in itemsToDelete)
{
wixData.remove("oppositeSearch", itemsToDelete[i]._id, options);
}
returnoptions.body = {
"Status": "Items Deleted = " + results.items.length
};
}
returnoptions.body = {
"Status": "No Data To Delete"
};
})
// something went wrong
.catch((error) => {
returnoptions.body = {
"Error": error
};
console.log("error in deleteing old data");
});
}
function getUniqueCities(items) {
const citiesOnly = items.map(item => item.city);
// Return an array with a list of unique cities
return [...new Set(citiesOnly)];
}
function buildOptions(uniqueList) {
return uniqueList.map(curr => {
return {value:curr, label:curr};
});
}
// filter results
export function buttonFilterResults_click(event) {
const CurrentCity = $w('#dropdownFilterCity').value;
// check if user has a pricing Plan
let user = wixUsers.currentUser;
let planName;
let userPlan;
user.getPricingPlans()
.then((pricingPlans) => {
userPlan = pricingPlans[0];
planName = userPlan.name;
if (planName === "Premium"){
showFilteredResults(CurrentCity, true);
}
else{
showFilteredResults(CurrentCity, false);
}
})
.catch(error => { // unknown user
showFilteredResults(CurrentCity, false);
});
}
I got the same error (noticed it for the first time this week). Seems to be a bug. I ended up deleting and recreating (not duplicating, which didn’t work) the repeater that the dataset was linked to.
Deleted previous comment…
I just checked this out and the problem appears to be related to a recent performance release. I’m checking this out further. Be right back.
Please try your site again. I adjusted your site configuration and it should be OK now.
Thanks, the error doesn’t repeat, but now I get this one:
cdn.enable.co.il/licenses/enable-L67241n0uotrp6y-1020-16084/init.js:1 Failed to load resource: net::ERR_BLOCKED_BY_CLIENT
And now the site loads much slower…
much much slower, unreasonably. please help
The new performance release is currently being carefully deployed so that sites remain available and reliable. The process continues and you should see significant performance improvements over the coming weeks - if not days.