Files
edx-platform/lms/static/js/student_account/AccountsClient.js
2018-05-11 12:32:22 -04:00

24 lines
561 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);
});
export {
deactivate,
};