Files
edx-platform/lms/static/js/student_account/AccountsClient.js
2020-04-20 16:17:25 +05:00

24 lines
568 B
JavaScript

import 'whatwg-fetch';
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 {
deactivate,
};