Answer the question
In order to leave comments, you need to log in
Why can't I call Event via post request?
On the client
fire() {
axios.get( APIENDPOINT + '/fired2').then((response)=>{
this.status = response.data.message;
})
Route::get('/fired2', function () {
NewUserRegistered::dispatch('lalla');
return response()->json([
'message' => 'Successfully fired through api (get)!',
], 201);
});
Route::post('/fired3', function (Request $request) {
return response()->json([
'message' =>$request->message // данные получаю нормально
], 201);
// NewUserRegistered::dispatch($request->input('message'));
event(new NewUserRegistered($request->message);
});
fire2() {
axios.post( APIENDPOINT + '/fired3', {'message':this.message}).then((response)=>{
this.status = response.data.message;
})
Answer the question
In order to leave comments, you need to log in
Install IDE.
She will immediately tell you that after return comes Unreachable code
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question