How to navigate from one page to another in javascript


I have a login screeen which basically sends username and password to another server and ffetch the accesstoken or sessionid. if the login is sucessful, i want to redirect to another page.

the login is happening in javascript method where i am making a rest api callout. so based on response, i want to redirect / show error message?

please let mek now how to achieve this

Sorry i found the result already