Hacker News new | past | comments | ask | show | jobs | submit login

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.



Though 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.


I 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 (!)




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: