Hello Leslie,
and where is the code? ? ?
Hello Leslie,
and where is the code? ? ?
import wixData from ‘wix-data’;
$w.onReady(function () {
//TODO:
});
export function btnLogin_click(event) {
wixData.query(“Partners_ID”)
.eq(“UserID”, “9999999999”)
.find()
.then((results) =>{
if (results.items.length == 0) {
console.log(“Invalid User ID”)
} else {
let firstItem = results.items[0];
console.log()
}
}
);
}
Hello Leslie,
try this one…
export function button1_click(event) {btnLogin_click()}
export function btnLogin_click(event) {
wixData.query("Partners_ID")
.eq("UserID", "9999999999")
.find()
.then((results) =>{
if (results.items.length > 0) {
let firstItem = results.items[0];
console.log("A user was found")
console.log(firstItem)
} else {
console.log("Invalid User ID")
}
}
);
}
To bring this code-snipet to work, you will need a button on your page, called —> “button1” which is connected to the code with an —> “onClick-Event”.
Good luck.
Thanks for your response…
however
“btnLogin_click” is getting called as the message “Invalid User ID” is printed on console.
Are there any db access credentials that come in force for retrieving the records?
For DB-permissions look here…
Check if your inputs are all alright and written right in code.
First things first, for comparison in JavaScript, we use triple equal ( === ) to mean equal, and ( !== ) to mean not equal.
Try something like this:
.then((results) =>{
if (results.items.length > 0) {
let firstItem = results.items[0];
console.log(firstItem)
} else {
console.log("Invalid User ID")
}
}
@Ahmad: Hello Ahmad, can’t see any differenz to my code (above)
Did you change something?
export function button1_click(event) {btnLogin_click()}
export function btnLogin_click(event) {
wixData.query("Partners_ID")
.eq("UserID", "9999999999")
.find()
.then((results) =>{
if (results.items.length > 0) {
let firstItem = results.items[0];
console.log("A user was found")
console.log(firstItem)
}
else {
console.log("Invalid User ID")
}
}
);
}