Problems when accessing route in Windows to delete using Vue.js

Asked

Viewed 54 times

0

I’m wanting to delete a record, but when accessing the route of the Laravel using the this. $http.delete gives me the error 419 Unknown status

Lockable method

public function destroy(Request $request){
    return User::destroy($request['id']);
}

Route:

Route::delete('user/delete/{id}', 'Admin\UserAccessController@destroy');

Vue:

deleteUser: function(id){

        this.$http.delete(this.$root.baseUrl + 'user/delete/'+id).then((response) => {
            if (response == 1) {
                this.users = this.deleteFromArray(this.users,id);
                this.$root.$refs.toastr.s('Usuário deletado com sucesso!');
            } else {
                this.$root.$refs.toastr.e('Não foi possível deletar o usuário!');
            }
        }).catch(function(e) {
            console.log(e);
            this.$root.$refs.toastr.e('Ocorreu um erro ao deletar usuário!');
        });

    },

Does anyone know what it can be?

1 answer

0


It is necessary to put a header. It was like this:

this.$http.delete(this.$root.baseUrl + 'user/delete/'+id,{headers:{
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }})

Browser other questions tagged

You are not signed in. Login or sign up in order to post.