20 lines
589 B
JavaScript
20 lines
589 B
JavaScript
export const buildUrl = (appBase, path) => new URL(path, appBase).toString();
|
|
|
|
export const postAction = async (url, csrf, data = {}) => {
|
|
const body = new URLSearchParams({ ...data, [csrf.key]: csrf.token });
|
|
return fetch(url, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
'Accept': 'application/json',
|
|
'X-Requested-With': 'fetch'
|
|
},
|
|
body
|
|
});
|
|
};
|
|
|
|
export const badgeHtml = (gridjs, value = '') => {
|
|
const safe = value ?? '';
|
|
return gridjs.html(`<span class="badge" data-variant="neutral">${safe}</span>`);
|
|
};
|