Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace $.ajax() with fetch() #5925

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

asdil12
Copy link
Member

@asdil12 asdil12 commented Sep 13, 2024

assets/javascripts/openqa.js Outdated Show resolved Hide resolved
assets/javascripts/tests.js Outdated Show resolved Hide resolved
@@ -23,6 +23,16 @@ function setupForAll() {
});
}

function getCSRFToken() {
return document.querySelector('meta[name="csrf-token"]').content;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it makes more sense to give this element an ID and use document.getElementById.

@Martchus
Copy link
Contributor

Looks generally good so from my side you could go ahead and change more places this way.

@asdil12 asdil12 force-pushed the fetch branch 13 times, most recently from 4bc8f1a to 7e08662 Compare September 18, 2024 15:01
success: () => {
fetchWithCSRF(deleteButton.dataset.deleteUrl, {method: 'DELETE'})
.then(response => {
if (response.status != 200) throw `Server returned ${response.status}: ${response.statusText}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why response.status is limited on 200. I wonder if response.ok is more appropiate in those if https://developer.mozilla.org/en-US/docs/Web/API/Response/ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants