X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fmodules%2Fcontrib%2Fpermissions_by_term%2Fjs%2Fsrc%2Fasync-function%2Ffetch-from-backend.js;fp=web%2Fmodules%2Fcontrib%2Fpermissions_by_term%2Fjs%2Fsrc%2Fasync-function%2Ffetch-from-backend.js;h=717a3c4a170393ff8b689c97ca5f3f6543324f2c;hb=059867c3f96750652c80f39e44c442a58c2549ee;hp=0000000000000000000000000000000000000000;hpb=f8fc16ae6b862bef59baaad5d051dd37b7ff11b2;p=yaffs-website diff --git a/web/modules/contrib/permissions_by_term/js/src/async-function/fetch-from-backend.js b/web/modules/contrib/permissions_by_term/js/src/async-function/fetch-from-backend.js new file mode 100644 index 000000000..717a3c4a1 --- /dev/null +++ b/web/modules/contrib/permissions_by_term/js/src/async-function/fetch-from-backend.js @@ -0,0 +1,23 @@ +/** + * @returns array + */ +const fetchFromBackend = async () => { + let contentType = null; + if (window.location.href.indexOf('/node/add') !== -1) { + contentType = window.location.href.split("/").pop(); + } + + let url = '/admin/permissions-by-term/access-info-by-url?url=' + window.location.pathname; + if (contentType !== null) { + url = '/admin/permissions-by-term/access-info-by-content-type/' + contentType; + } + + return await fetch(url, { credentials:'include' }) + .then(function(response) { + return response.json(); + }).then(function(data) { + return data; + }); +}; + +export default fetchFromBackend; \ No newline at end of file