Skip to content

Commit 3938aea

Browse files
author
zsbahtiar
committed
feat(initGlobalDeleteButton): add option http method delete when data-method is delete
1 parent c8dbc29 commit 3938aea

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

web_src/js/features/common-button.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {POST} from '../modules/fetch.ts';
1+
import {DELETE, POST} from '../modules/fetch.ts';
22
import {addDelegatedEventListener, hideElem, queryElems, showElem, toggleElem} from '../utils/dom.ts';
33
import {fomanticQuery} from '../modules/fomantic/base.ts';
44
import {camelize} from 'vue';
@@ -62,7 +62,10 @@ export function initGlobalDeleteButton(): void {
6262
}
6363
}
6464

65-
const response = await POST(btn.getAttribute('data-url'), {data: postData});
65+
const method = btn.getAttribute('data-method')?.toUpperCase() || 'POST';
66+
const response = method === 'DELETE'
67+
? await DELETE(btn.getAttribute('data-url'))
68+
: await POST(btn.getAttribute('data-url'), {data: postData});
6669
if (response.ok) {
6770
const data = await response.json();
6871
window.location.href = data.redirect;

0 commit comments

Comments
 (0)