i am using laravel project with vuejs and inertiajs. i want to make user login and after login i want the user to redirect to test.vue file, which i created just for learning. i made a registration form after submit registration form i call a function login, i.e i want the same user to login, who registered. my set login function is working properly, but failed to redirect to vue page using inertia render.
RegistrationForm.vue
SubmitRegistration(){
this.$v.$touch();
if (this.$v.$invalid) return;
axios.post('submitRegistrationForm',this.form)
.catch(({ response }) => {
this.$toast.error(response.data.message, 'error', {timeout:3000});
}).then(({ data }) => {
this.setLogin();
});
},
setLogin(){
const data = {
email: this.form.email,
password: this.form.password
}
axios.post('loggedInUser',data)
.catch(({ response }) => {
this.$toast.error(response.data.message,'error', {timeout: 3000});
});
},
web.php
Auth::routes();
Route::post('loggedInUser',[FrontEndController::class,'authenticate'])->name('login.attempt');
FrontEndController.php
public function authenticate(Request $request)
{
$credentials = $request->only('email', 'password');
if (Auth::attempt($credentials)) {
return Inertia::render('Layouts/Test');
}
}
test.vue
<template>
<h1>
Hello
</h1>
</template>