Open a new page after the a successful request

I trying to navigate to another page but i am getting an exception
" Cannot read property ‘$router’ of undefined"
plus my pages are located on a separate file
app.request({
url:‘http://localhost/login.php’,
method:‘POST’,
data:{username:user,password:pass},
statusCode:{
200:function(xhr){
if(xhr.response === “Success”){
app.dialog.alert(‘Success Logged in’ + xhr.response)
console.log(xhr.response)
view.$router.navigate({
path:’/mainapp/’,
url:’./pages/home.html’
})

                                }else{
                                    app.dialog.alert('Failed to login ' + xhr.response)
                                    console.log(xhr.response)
                                   
                                }  
                            },
                            500:function(xhr){
                                    app.dialog.alert('There is an error with the network '+ xhr.response)
                                  }
                            } 
                    })

Try this if you are using componentUrl in your router.
app.views.main.router.navigate({
name: ‘home’,
});

1 Like