2020-07-24 04:56:55 +02:00
|
|
|
export const post = (url, params) =>
|
|
|
|
fetch(url, {
|
|
|
|
method: 'post',
|
|
|
|
cache: 'no-cache',
|
|
|
|
headers: {
|
|
|
|
Accept: 'application/json',
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
},
|
|
|
|
body: JSON.stringify(params),
|
|
|
|
}).then(res => (res.status === 200 ? res.json() : null));
|
2020-07-24 07:07:57 +02:00
|
|
|
|
|
|
|
export const hook = (_this, method, callback) => {
|
|
|
|
const orig = _this[method];
|
|
|
|
|
|
|
|
return (...args) => {
|
|
|
|
callback.apply(null, args);
|
|
|
|
|
|
|
|
return orig.apply(_this, args);
|
|
|
|
};
|
|
|
|
};
|