I have an application that the front end is VueJS / Quasar and the server is hapiJS. I'm working on the login part and would like to know how to redirect the page after receiving confirmation from the server that the login information is correct.
Server:
server.route({
path: '/login',
method: 'post',
handler: function (request, reply) {
let user = request.query.login;
let pass = request.query.senha;
let pesquisa = {'usuario': {$eq: user}, 'senha': {$eq: pass}};
db.open(function (err, mongoclient) {
mongoclient.collection('login', function (err, collection) {
collection.find(pesquisa).toArray(function (err, results) {
if (err) {
console.log(err);
mongoclient.close()
} else {
if (results === pesquisa) {
console.log('Login correto');
mongoclient.close();
}
}
})
})
})
}
});
Client:
entrar () {
let self = this
axios({
url: '/server/login',
method: 'post',
params: self.pessoa
})
.then(function (response) {
console.log(response.data)
this.$route.router.go(response.data)
})
.catch(function (error) {
console.log(error)
})
}
What should I do in the response from the server to the client ??? How to redirect the page on the client after receiving the data from the server ??