Hello,
I have added some code to my site and it seems like the code is right but I keep getting the “Parsing Error: Unexpected Token ;” message. Please could someone assist?
Here is my page code:
Here is my back-end Code:
Kind Regards,
Brittani
#button1_click
Self explanatory in your code…
Unexpected token means error in the code and it is highlighted where the error is.
Just delete the red underlined ; and see what happens…
@givemeawhisky I am now trying to get my results to show properly. This is what is currently showing when I test the site:
Instead of [object Object], I would like the Variables shown in the Results: Array to show.
I am trying implement this code for my website, but having an issue that I couldn’t fix it. Anyone please help. Thanks
import wixData from ‘wix-data’;
export function searchForDuplicateUsernames(value) {
return wixData.query(“MembersLogin”)
.eq(“username”, value.username)
.find()
.then((results) => {
return results.items.length;
})
. catch ((err) => {
let errorMsg = err;
})
}
// emailAddress
export function searchForUsernamesIds(value) {
//This will check if the username and email is the same i.e, The username is not changed by the user
return wixData.query(“MembersLogin”)
.eq(“username”, value.username)
.eq(“emailAddress” , value.emailAddress)
.find()
.then((results) => {
return results.items.length;
})
. catch ((err) => {
let errorMsg = err;
})
}
export function MembersLogin_beforeInsert(item, context) {
return searchForDuplicateUsernames(item, context).then((res) => {
if (res > 0) {
return Promise.reject(‘This username is already taken’);
}
return item;
});
}
export function MembersLogin_beforeUpdate(item, context, value) {
//courtesy of Salman from the Totally Codable Code community that helped finish this code
//fb.com/salman2301 or salmanhammed77@gmail.com preferred facebook
return searchForUsernamesIds(item, context).then((res) => {
if (res > 0) {
// the user name is not change but some other value is changed
return Promise.resolve(‘Updated the changes’);
} else {
// The username is changed , Checking if the username value is taken by some other member or not
return searchForDuplicateUsernames(item, context).then((res) => {
if (res > 0){
return Promise.reject(‘This username is already taken’);
}
})
}
return item;
});
}
export function onUpDate(value) {
return wixData.query(“MembersLogin”)
.eq(“username”, value.username)
.find()
.then((results) => {
return results.items.length;
})
. catch ((err) => {
let errorMsg = err;
})
}
Good morning @muktatejas . The first thing I noticed is
.eq(“username”, value.username) Should be .eq(“username”, username.value).
Try making that change to all applicable code and that should get you going.
Hi @muktatejas , were you able to get your site functioning properly?
@code-queen
Looking at the code further and you are using a good tutorial provided by Nayeli (Code Queen) which searches for duplicate usernames.
https://codequeen.wixsite.com/membership-dashboard
Youtube video for above tutorial:
https://www.youtube.com/watch?v=yLCOqsVHhD0
Nayeli is a Wix Expert herself and has provided this tutorial herself through her own website and not through Wix itself, therefore you would first be better off contacting her directly to see if she can help you implement her code from her tutorial. Then please come back to this forum if she can’t help you with your issue.
Finally, if you are pasting up code, you need to paste all your code as this tutorial uses page code for two seperate pages as well as backend code too, so your problem might not be in your backend code which you have pasted up by itself only.
Hello, im a part time developer for my wix website. I tried to build a range of filters for my semi hot runners business. I encounter this error and would be great if someone could help me understand what I am doing wrong, if there are wordings i am missing. thanks a lot.
below is the code I have written following corvid tutorial.
https://www.youtube.com/watch?v=QhMKnm1f6EU
///////////////////////////////////////
import wixData from ‘wix-data’;
export function button1_click(event, $w) {
$w(“semi hot runner”).setFilter(wixData.filter()
.contains(“title”, $w(‘#dropdown1’).value)
.ge(“plasticMaterial”, $w(‘dropdown2’).value)
.ge(“manifoldType”, $w(‘dropdown3’).value)
.ge(“moldNumber”, $w(‘dropdown4’).value)
.ge(“polyflowJobNumber”, $w(‘dropdown5’).value)
.then((results) => {
console.log(“Dataset is now filtered”);
$w(“#table1”).data = results.items;
}). catch ((err) => {
console.log(err);
});
$w(‘#table1’).expand()};
}
Without checking your code, you need to first off make sure that you have matching pairs of opening and closing parentheses and curly brackets.
So you have matching pairs of open ( and closed ) and open { and closed }
Try this and you need to change the dataset to the dataset id name which can be found on the top left of the dataset icon if you hover over it, or if you look at the properties panel for the dataset itself, plus also make sure that you have added the onClick event in the properties panel for your button, see link below for more info.
Corvid: Working with the Properties Panel
It will most likely be #dataset1 if that is the only dataset on your page, however you need to check it is correct and matches so that your code works with it.
import wixData from 'wix-data';
$w.onReady(function () {
});
export function button1_click(event, $w) {
$w("#yourdatasteIDname").setFilter(wixData.filter())
.contains("title", $w('#dropdown1').value)
.ge("plasticMaterial", $w('dropdown2').value)
.ge("manifoldType", $w('dropdown3').value)
.ge("moldNumber", $w('dropdown4').value)
.ge("polyflowJobNumber", $w('dropdown5').value)
.then((results) => {
console.log("Dataset is now filtered");
$w("#table1").data = results.items;
})
.catch((err) => {
console.log(err);
$w('#table1').expand();
});
}
Please note as well that this is an old post and you would be better suited adding your post as a new post as yours is not the same as above.
This post is now being closed.