Wix query issue to send me to proper dynamic page based on user -- Solved

So i put the email of my custom user in the dealer table it has the id location for some reason seperate problem. This is my attempt to get teh dealer id to link them on button click to a eidt page. I get an error when I click my button. Here is the code

My Code
let email = wixUsers.currentUser.getEmail();

wixData.query(“Dealers”)
.eq(“location”, email)
.then( (results) => {
return results.items[0]._id;
} ).then (
(id) => {
wixLocation.to(Dealers/EditProducts/id);
}
);

Error:
_wixData2.default.query().eq().then is not a function

So I got a little farther. Now I can’t get the dashes out of the id. So teh link is wrong

My Code

wixUsers.currentUser.getEmail().then(
(email) => {
console.log(email)
wixData.query(“Dealers”)
.eq(“location”, email)
.find()
.then( (results) => {
let items = results.items;
let item = items[0];
console.log(item)
return item._id;
} ).then(
(innerId) => {
let id = innerId.toString().replace(‘-’, ‘’);
console.log(id);
return wixLocation.to(Dealers/EditProducts/+ id);
}
). catch (
(err) => {
console.log(err)
}
);

Ok got it to work. Here is a function to send your custom users to a dynamic page based on email of the user they used to create! I’m so happy

My Code
export function profileButton_click(event) {
wixUsers.currentUser.getEmail().then(
(email) => {
wixData.query(“Dealers”)
.eq(“location”, email)
.find()
.then( (results) => {
let items = results.items;
let item = items[0];
return item._id;
} ).then(
(innerId) => {
let baseUrl = wixLocation.baseUrl;
let id = innerId.toString();
return wixLocation.to(baseUrl + /Dealers/EditProducts/+ id);
}
). catch (
(err) => {
console.log(err)
}
);
}
)
}