đĄ Les navigateurs ne supportent que GET et POST en natif dans les formulaires. DĂ©couvrez comment gĂ©rer DELETE et PUT.
Situation de base : https://github.com/dupontdenis/mongoose-TD-CRUD.git
Delete/update
- In this repository we keep things explicit and simple by using POST endpoints for update and delete actions (for example
/posts/:id/updateand/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-overrideis a middleware used to turn a POST into a PUT/DELETE on the server (usually by reading a hidden_methodfield 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.htmlandpublic/js/app.js) usesfetch()to perform CRUD operations.
Avancé : une seule vue pour edit/create https://github.com/dupontdenis/CRUD.git