Hello,
I am getting this error on my live site: TypeError: Cannot read property 'type' of undefined
However, in my preview site I do not have any problems.
This pertains to JS that runs at https://www.ryanandkirsten.com/rsvp.
I use this function to perform a fuzzy search against a database collection as the user types in the input.
export function fuzzyGuestSearch(event, $w) { let searchInput = $w('#input1').value var options = { shouldSort: true, includeScore: true, threshold: 0.5, location: 0, distance: 50, maxPatternLength: 32, minMatchCharLength: 3, keys: ['fullName'] }; if (searchInput.length > 0) { wixData.query("wedding-guests") .limit(1000) .ne("rsvpComplete", true) .find() .then((results) => { let list = results.items; var fuse = new Fuse(list, options); // "list" is the item array return fuse.search(searchInput); }) .then((result) => { if (result.length > 0) { let score = result[0].score if (score <= .4) { let guestInput = result[0].item session.setItem("user", JSON.stringify(guestInput)) console.log("Dataset is ready to be filtered by " + JSON.stringify(guestInput)) $w('#button1').enable(); } else { console.log("No Results") $w('#button1').disable(); } } }) } }
Then when the user clicks the next button I run this code inside of onReady
$w('#button1').onClick((event, $w) => { let user = JSON.parse(session.getItem("user")) let groupKey = user.groupKey let guest = user.guestAllowed console.log(guest) $w("#dataset2") .setFilter(wixData.filter().eq("groupKey", groupKey)) .then(() => { console.log("DataSet is now Filtered"); if (guest === true) { $w('#box1') .expand() .then($w('#slideshow1') .changeSlide(1)) } else { $w('#slideshow1') .changeSlide(1) } }) .catch((err) => { console.log("There was an error filtering the dataset: " + err); }) });
Please let me know if there is any other information I can provide.
Hey Yisrael,
I decided to rewrite it all last night. I removed all references to datasets and I am instead populating my repeaters and accessing my collections data with calls to wixData.query().
This seems to be working better but I have not finished rewriting all of it yet.
Hey Ryan,
I'm confused.... I don't see any dataset filtering. In fact, I don't see where you are referencing either of the two datasets that are on the RSVP page. Both datasets are read-write and are connected to the same collection. It doesn't make sense that you are getting an error on the dataset. Where am I going wrong?
Yisrael
@shan - I did check the database collection and ensure it was set to anyone.
@Yisrael - I fixed the issue with having 2 onReadys but that didn't make a difference. As for fuse.js, there doesn't actually seem to be any issue with the way that module works. It is searching my database collection array without error. I am going to try and disable it just in case and run a test that way.
Also the error is definitely happening with my dataset filtering function because my console is showing:
There was an error filtering the dataset: TypeError: Cannot read property 'type' of undefined
Which is thrown by my function which is filtering my dataset.
Your RSVP page has two onReady() functions which is invalid. The last onReady() overwrites the previous.
Also, you have errors in the fuse.js file. You need to take care of required dependencies.
I don't see how it even works in Preview.
Good luck,
Yisrael
Are you sure your Database Collection permission is set to 'Anyone' ?