DELETE Request failed in HTMX

I tried to execute a DELETE request inside htmx, but i can’t execute that. I don’t know what is the reason.
The code of htmx delete button:

<button
      class="icon-button"
      hx-delete="/api/method/Book/delete_book?name={{ book.name }}"
      hx-target="#book-list"
      hx-swap="outerHTML remove"
    >

The book.py code:

@frappe.whitelist(allow_guest=True)
def delete_book(name):
    if frappe.db.exists("Book", name):
        frappe.delete_doc("Book", name)
        frappe.db.commit()
        return {"message": "Book deleted successfully"}
    else:
        frappe.throw("Book not found")

The output img:

1 Like

Use error handling to get exact error. Sometimes we can’t delete, if the document have connections.

1 Like

Tell me if you got any error now??

hey @MachoMaheen, can you please share a link to your project and/or github repo, whichever you’re comfortable with.

I’ve been wondering what ERPNext and HTMX would look like

1 Like

sorry for the late reply. This is the link of the repo: GitHub - MachoMaheen/article_frappe: Article Generator using Frappe and HTMX

1 Like

willl try and let u know