Pages

đŸš© PUT/DELETE how-to

 đŸ’Ą Les navigateurs ne supportent que GET et POST en natif dans les formulaires. DĂ©couvrez comment gĂ©rer DELETE et PUT. 

Méthode CRUD

Support natif HTML

Solution avec Express

Create (POST)

✅ Oui

<form method="POST">

Read (GET)

✅ Oui

<form method="GET">

Update (PUT)

❌ Non

method-override + POST

Delete (DELETE)

❌ Non

method-override + POST




Delete/update

  • In this repository we keep things explicit and simple by using POST endpoints for update and delete actions (for example /posts/:id/update and /posts/:id/delete). Those endpoints accept normal POST form submissions and return normal redirects or rendered pages.

  • HTML forms only submit GET or POST. method-override is a middleware used to turn a POST into a PUT/DELETE on the server (usually by reading a hidden _method field or a query parameter).

  • This project was converted to an API-first, client-rendered demo where the server returns JSON and the frontend (in public/index.html and public/js/app.js) uses fetch() to perform CRUD operations.




AvancĂ© : une seule vue pour edit/create https://github.com/dupontdenis/CRUD.git