V
V
vadik_nv2021-07-02 15:33:28
Laravel
vadik_nv, 2021-07-02 15:33:28

Why axios.put returns status 200 but doesn't update the data?

I am learning laravel + vue.
I send a request from the front to the back:

updateChe(context, credentials) {
            axios.put('http://laravel.api/api/tasks/' + credentials.id, credentials)
        }

an updated object comes to credentials, checked.

the request gets into the controller method on the back:
public function update(Request $request, Task $task): TaskResource
    {
        $this->validateAuthUserTask($task);

        $task->update($request->all());

        return new TaskResource($task);
    }

in the controller, the updated object is normally caught via dd($request);
In the response (response) I get the old (not updated) object.
The object in the database is not updated. I tried to send different headers with the request - it did not help (maybe not the ones you need)
How to make a put request so that it works correctly?
Through POSTMAN it worked fine.
There is authentication through tokens.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jazzus, 2021-07-02
@vadik_nv

Write fillable models

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question