Hi,
I am facing problems with calling functions from the web modules.
I am trying to do up a member profile page whereby the create button is enabled (and the update button is disabled) when there is no corresponding record in a ‘Members Table’.
If there is a corresponding record, the create button is disabled (and the update button is enabled).
Backend code (File Name - trialBacData.jsw):
import wixData from ‘wix-data’;
export function getUsDa(userRetrievalID) {
wixData.query("Members").eq("userID",userRetrievalID).find().then(results => {
let finalResult;
if(results.length===1)
{
finalResult = true;
}
else
{
finalResult = false;
}
console.log(finalResult);
**return finalResult;**
} );
}
Front End Code:
import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;
import {getUsDa} from ‘backend/trialBacData’;
$w.onReady(function () {
var usID = **wixUsers.currentUser.id** ;
console.log("Hello World");
getUsDa(usID).then(result => {
console.log(result);
if(result)
{
$w("#createBtn").disable();
$w("#updateButton").enable();
}
});
Result:
When I logged the result into the console, all i get is a null value when ideally i should have gotten a true or false value .
Can anyone help me out with this code? Maybe point out the mistakes please ><