Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | 39x 6x 5x 5x 5x 5x 5x 3x 3x 3x 3x 3x 3x 3x 3x 39x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x | 'use strict';
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.promise.js";
import "core-js/modules/es.promise.finally.js";
import "core-js/modules/web.timers.js";
export var fetchRequest = function fetchRequest(comp, url, options, callbacks, delay) {
/* Makes a request with fetch.
Args:
- url: The user to make the request to.
- options: Options Object for fetch: https://developer.mozilla.org/en-US/docs/Web/API/fetch
- callbacks:
- success(data)
- error(error)
- finally()
- delay: Milliseconds to delay the request.
*/
if (comp.state.loading) return;
comp.resetState();
comp.state.loading = true;
var delayRequest = delay ? delay : 0;
comp.render(function () {
setTimeout(function () {
fetch(url, options).then(function (response) {
return response.json();
}).then(function (data) {
Iif (data.error) {
comp.state.error = true;
if (callbacks && callbacks['error'] instanceof Function) {
callbacks['error'](data);
}
} else {
comp.state.success = true;
Iif (callbacks && callbacks['success'] instanceof Function) {
callbacks['success'](data);
}
}
})["catch"](function (error) {
comp.state.error = true;
if (callbacks && callbacks['error'] instanceof Function) {
callbacks['error'](error);
}
})["finally"](function () {
comp.state.loading = false;
Iif (callbacks && callbacks['finally'] instanceof Function) {
callbacks['finally']();
}
comp.render();
});
}, delayRequest);
});
};
export var axiosRequest = function axiosRequest(comp, config, callbacks, delay) {
/* Makes a request with Axios.
Args:
- config: Configuration Object for Axios: https://axios-http.com/docs/intro
- callbacks:
- success(response)
- error(error)
- finally()
- delay: Milliseconds to delay the request.
*/
Iif (comp.state.loading) return;
comp.resetState();
comp.state.loading = true;
var delayRequest = delay ? delay : 0;
comp.render(function () {
setTimeout(function () {
axios.request(config).then(function (response) {
comp.state.success = true;
Iif (callbacks && callbacks['success'] instanceof Function) {
var callbackResponse = callbacks['success'](response);
if (callbackResponse instanceof Object) response = callbackResponse;
}
})["catch"](function (error) {
comp.state.error = true;
if (callbacks && callbacks['error'] instanceof Function) callbacks['error'](error);
}).then(function () {
comp.state.loading = false;
Iif (callbacks && callbacks['finally'] instanceof Function) callbacks['finally']();
comp.render();
});
}, delayRequest);
});
}; |