Files
edx-platform/lms/static/js/student_account/AccountsClient.js
Feanil Patel f310c02aba build: Drop the whatwg-fetch polyfill.
This package polyfills the Fetch api but that API is now widely
available so I don't think we need this package anymore.
2025-03-05 08:58:35 -05:00

24 lines
638 B
JavaScript

import Cookies from 'js-cookie';
const deactivate = (password) => fetch('/api/user/v1/accounts/deactivate_logout/', {
method: 'POST',
credentials: 'same-origin',
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'X-CSRFToken': Cookies.get('csrftoken'),
},
// URLSearchParams + polyfill doesn't work in IE11
body: `password=${encodeURIComponent(password)}`,
}).then((response) => {
if (response.ok) {
return response;
}
throw new Error(response.status);
});
export {
// eslint-disable-next-line import/prefer-default-export
deactivate,
};