Greetings! I am currently working on setting up routing for my login component page to redirect to the dashboard component upon successful login. I have managed to receive responses from my local API with status codes 400 and 200 but I am unsure how to handle the redirection post login.
Below is the script code for the component: import axios from 'axios'
export default {
name: 'Login',
data () {
return {
email: '',
password: '',
error: ''
}
},
methods: {
login () {
axios.post('http://ztlab01/db-admin/app/v1/login', {
email: this.email,
password: this.password
}, {'Access-Control-Allow-Origin': '*'})
.then((response) => {
console.log(response.data)
if (response.data.code === 400) {
this.error = 'Invalid Credentials'
}
if (response.data.code === 200) {
this.error = ''
}
})
.catch(error => {
console.log(error)
})
}
}
}