Error Message code for login?

Hello I need to be able to display a error message when a login or register fails to my site my custom login code is as follows:

import wixUsers from ‘wix-users’;
import wixLocation from ‘wix-location’;

$w.onReady( function () {
$w(‘#loginNow’).onClick( function () {
let email = $w(‘#loginEmail’).value;
let password = $w(‘#loginPassword’).value;
wixUsers.login(email, password)
.then(() => {
wixLocation.to(‘/my-account’);
})
})
})

I just need it so when someone clicks login and it fails or is incorrect some text is shown.

Thanks a lot!

Just use a error message in your code, here is what I have on mine.

import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
import wixWindow from 'wix-window';

$w.onReady(function () {
 $w("#forgotPassword").onClick( (event) => {
    //wixWindow.lightbox.close()
   wixUsers.promptForgotPassword()
   .then( ( ) => {
   //
   } )
    .catch( (err) => {
 let errorMsg = err;  //"The user closed the forgot password dialog"
    });
 });
});

export function loginButton_click(event) {

 let email = $w("#email").value;
 let password = $w("#password").value;

 wixUsers.login(email, password)
   .then( () => {
     console.log("User is logged in");
     wixLocation.to("/account/my-account");  //Change the URL ending to whatever page you want to send the user to after they log in.
   } )
    .catch( (err) => {
     console.log(err);
     $w("#errorMessage").expand(); // You can delete this line if you are not going to add an error message. Use a regular text element set to 'collapse on load' from the Properties Panel.
   } ); 
}

You could also look at doing custom validations, all depends on what you need and how much work you are wanting to do for it.
https://support.wix.com/en/article/corvid-about-validating-user-input-with-code
https://support.wix.com/en/article/working-with-user-input-validation-in-the-settings-panel