I am building a lightning community using LWC, where on successful login trying to navigate to standard home page of the community, but i see no URL redirection is happening.Below is the logic i have written.
import { LightningElement } from 'lwc';
import authenticateLogin from "@salesforce/apex/Login_Controller.authenticateLogin";
import { NavigationMixin } from 'lightning/navigation';
export default class LoginPage extends NavigationMixin(LightningElement){
handleLogin(event) {
var userName= this.template.querySelector(".userName");
var password = this.template.querySelector(".password");
authenticateLogin({ userName: userName.value , password : password.value})
.then(result => {
console.log("Auth success ! ");
this[NavigationMixin.Navigate]({
type: 'comm__namedPage',
attributes: {
pageName: 'home'
}
});
console.log("Navigation success ! ");
})
.catch(error => {
this.error = error;
console.log("error "+error);
})
.finally(() => {
console.log("finally ");
});
}
}
On console.log i see both "Auth success !" and "Navigation success !" are coming but the redirection is not happening, am i doing anything wrong in this.
This is the help doc i am following to achieve this - https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.reference_page_reference_type