-
Notifications
You must be signed in to change notification settings - Fork 205
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
base: master
Are you sure you want to change the base?
Conversation
e838560
to
9aed887
Compare
@@ -23,6 +23,16 @@ function setupForAll() { | |||
}); | |||
} | |||
|
|||
function getCSRFToken() { | |||
return document.querySelector('meta[name="csrf-token"]').content; |
There was a problem hiding this comment.
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
.
9f07f1a
to
0c65ba6
Compare
Looks generally good so from my side you could go ahead and change more places this way. |
4bc8f1a
to
7e08662
Compare
assets/javascripts/comments.js
Outdated
success: () => { | ||
fetchWithCSRF(deleteButton.dataset.deleteUrl, {method: 'DELETE'}) | ||
.then(response => { | ||
if (response.status != 200) throw `Server returned ${response.status}: ${response.statusText}`; |
There was a problem hiding this comment.
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
b507723
to
68bc207
Compare
ee75d64
to
7724f4a
Compare
Ticket: https://progress.opensuse.org/issues/166310 Co-authored-by: Martchus <[email protected]>
Ticket: https://progress.opensuse.org/issues/166310