Hi. I am new to wix code.
I have some experience with Javascript, C++ and Visual Studio
I started making my first website two months ago. It is a business website which I want to use to get in touch with customers and keep track of devices they sent me for repair.
I love the wix editor. Super simple. My coding however is turning to a mission.
So far I have done the following:
2x collections - 1 for my customer’s data and 1 for the data about a specific device.
I have read through the forum and created the following code:
export function searchbutton_click(event) {
//Add your code for this event here:
$w("#button4").show();
$w("#button5").show();
let tid = $w(‘#input1’).value;
wixData.query(‘Tickets’)
.eq(‘ticketId’, tid)
.then(res => {
if (res.length === 0) {
// name not found in DB
}
else if (res.length > 1) {
// multiple results = BUG
}
else {
$w(‘#input2’).value = res.items[0].deviceMake;
$w(‘#input3’).value = res.items[0].deviceModel;
$w(‘#input4’).value = res.items[0].note;
$w(‘#input6’).value = res.items[0].DevicePasscode;
$w(‘#input5’).value = res.items[0].problem;
wixData.query(‘Customers’)
.eq(‘customer_email’, res.items[0].customer_email)
.then(cus => {
if (cus.length === 0) {
// name not found in DB
}
else if (cus.length > 1) {
// multiple results = BUG
}
else
{
$w(‘#textInput1’).value = cus.items[0].postName;
$w(‘#textInput2’).value = cus.items[0].phoneNumber;
$w(‘#textInput3’).value = cus.items[0].billing_email;
$w(‘#textInput6’).value = cus.items[0].addressLine1;
$w(‘#textInput5’).value = cus.items[0].post_code;
$w(‘#textInput4’).value = cus.items[0].address_notes;
}
});
}
});
}
The code is suppoused to get the data from my devices database for 1 specific device.
Then it should display all the data to my admin page.
Then it should find the customer who sent the device in the 2nd database
Finally it should display the customer’s details in the page.
However what happens instead is I get this error every time I press the button:
TypeError: _wixData2.default.query(…).eq(…).then is not a function
I know this is definitely something which I the user have coded wrong.
My question is is there no way that the editor can catch that kind of errors while I am writing the code, or at least show on which row the mistake is?
If that is not possible could you please recommend any debugging tool i could use?
I enjoy working with wix, but I’m struggling to achieve my results.
Any help will be appreciated