3 ms·
I was gonna write a snarky comment about using a <button formmethod="DELETE"> but apparently, the only methods allowed on a <form>s and <button>s are GET and PO
by runarberg 8y ago
I was gonna write a snarky comment about using a <button formmethod="DELETE"> but apparently, the only methods allowed on a <form>s and <button>s are GET and POST.
I wonder why these limitations. Especially since you can get past this with an:
button.addEventHandler('click', () => {
fetch('/path/to/resource', { method: 'DELETE' })
});
which seems way less accessible then to have the method there right there as an attribute.
- adrianratnapala 8y agoThough as dragonwriter points out, using a button+POST to fake a delete is much better than using a link. Api-wise that's a reason to mux your puts and deletes in the POST handler and not in the GET handler, since it force the HTML to use buttons rather than links that might get crawled.
- runarberg 8y agoI still don’t understand why: <button formmethod="POST"> is better then: <button formmethod="DELETE"> When the former actually calls DELETE behind the scenes. I would think a crawler would prefer the latter, except for the fact that it is invalid (!)