sergionc
1 month ago
491
3
Laravel

delete record with fetch api

Posted 1 month ago by sergionc

I am trying to delete a record using fetch api but I get the following error: The GET method is not supported for this route. Supported methods: DELETE.

button:

                        <button class="btn btn-danger btn-sm"
                            onclick="deletePersona({{$persona->id}})">
                            <i class="fas fa-times">
                            </i>
                        </button>

Code js:

function deletePersona(id) { fetch("/persona_eliminar/" + id, { method: "DELETE", }) .then((res) => res.json()) .then((response) => { console.log(response); }); }

Please sign in or create an account to participate in this conversation.