mercredi 21 septembre 2016

Laravel5: TokenMismatchException in compiled.php line 3123:

THE SITUATION:

Sorry in advance if it has already been asked. But no matter what I can never make it works.

I am using Laravel 5 as API.

I have a simple function to edit a task.

I am testing it through my web app or through Postman.

I am always getting this error:

TokenMismatchException in compiled.php line 3123:

TokenMismatchException

THE CODE:

The function:

public function updateTask(Request $request)
{
    $id = $request->input('id');

    $task = Task::find($id);
    $task->name = $request->input('name');
    $task->type = $request->input('type');

    $task->save();

    return $task;
}

The route (attempt 1):

Route::post('update', 'TaskController@updateTask');

The route (attempt 2):

Route::group(['middleware' => ['api']], function () {

    Route::post('update', 'TaskController@updateTask');
});

THE QUESTION:

Why I am getting that error?

I have a similar function to create a task that is working fine. I access it from my web app and I get no error...

Thanks for help!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire