Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static setAdminOption(option, value, handleSuccess, handleError) {
- const formData = `option=${option}&value=${value}`;
- // create an AJAX request
- const xhr = new XMLHttpRequest();
- xhr.open('post', __ROOT_PATH__ + 'api/adminS');
- xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
- xhr.responseType = 'json';
- xhr.addEventListener('save', () => {
- if (xhr.status === 200) {
- handleSuccess(xhr.response.token);
- } else {
- // failure
- // change the component state
- const errors = xhr.response.errors ? xhr.response.errors : {};
- errors.summary = xhr.response.message;
- handleError(errors);
- }
- });
- xhr.send(formData);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement