Level 47
login?
axios.post('your/login/endpoint',{
username: username-in-form,
password: password-in-form
})
what is the backend auth package you using? i suggest Laravel Sanctum
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
I have the create method in my controller. There I have the following so far:
$salutation->created_by = Auth::user()->name;
But now it does not work if I make the call with Vue.js:
onSubmitSalutation(evt) {
evt.preventDefault()
this.errors = {};
axios.post('/api/postSalutation', {
description: this.description
}).then(response => {
this.$bvModal.hide('createSalutation');
this.getSalutations();
}).catch(error => {
if (error.response.status === 422) {
this.errors = error.response.data.errors || {};
}
});
},
So my question is, how can I send the username, or even better authenticate myself for the API, so that I can use the middelware:
Route::group(['middleware' => ['auth']], function () {
Route::post('/postSalutation', 'SalutationsController@store');
});
Please or to participate in this conversation.