Use fetch helpers instead of fetch (#27026)
WIP because: - [x] Some calls set a `content-type` but send no body, can likely remove the header - [x] Need to check whether `charset=utf-8` has any significance on the webauthn calls, I assume not as it is the default for json content. - [x] Maybe `no-restricted-globals` is better for eslint, but will require a lot of duplication in the yaml or moving eslint config to a `.js` extension. - [x] Maybe export `request` as `fetch`, shadowing the global.
This commit is contained in:
parent
8099238618
commit
ae8e8f055e
17 changed files with 70 additions and 98 deletions
|
@ -5,6 +5,7 @@ import {htmlEscape} from 'escape-goat';
|
|||
import {confirmModal} from './comp/ConfirmModal.js';
|
||||
import {showErrorToast} from '../modules/toast.js';
|
||||
import {createSortable} from '../modules/sortable.js';
|
||||
import {DELETE, POST} from '../modules/fetch.js';
|
||||
|
||||
function initRepoIssueListCheckboxes() {
|
||||
const $issueSelectAll = $('.issue-checkbox-all');
|
||||
|
@ -146,13 +147,7 @@ function initPinRemoveButton() {
|
|||
const id = Number(el.getAttribute('data-issue-id'));
|
||||
|
||||
// Send the unpin request
|
||||
const response = await fetch(el.getAttribute('data-unpin-url'), {
|
||||
method: 'delete',
|
||||
headers: {
|
||||
'X-Csrf-Token': window.config.csrfToken,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
const response = await DELETE(el.getAttribute('data-unpin-url'));
|
||||
if (response.ok) {
|
||||
// Delete the tooltip
|
||||
el._tippy.destroy();
|
||||
|
@ -166,14 +161,7 @@ function initPinRemoveButton() {
|
|||
async function pinMoveEnd(e) {
|
||||
const url = e.item.getAttribute('data-move-url');
|
||||
const id = Number(e.item.getAttribute('data-issue-id'));
|
||||
await fetch(url, {
|
||||
method: 'post',
|
||||
body: JSON.stringify({id, position: e.newIndex + 1}),
|
||||
headers: {
|
||||
'X-Csrf-Token': window.config.csrfToken,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
await POST(url, {data: {id, position: e.newIndex + 1}});
|
||||
}
|
||||
|
||||
async function initIssuePinSort() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue