Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / permissions_by_term / js / src / async-function / fetch-from-backend.js
1 /**
2  * @returns array
3  */
4 const fetchFromBackend = async () => {
5   let contentType = null;
6   if (window.location.href.indexOf('/node/add') !== -1) {
7     contentType = window.location.href.split("/").pop();
8   }
9
10   let url = '/admin/permissions-by-term/access-info-by-url?url=' + window.location.pathname;
11   if (contentType !== null) {
12     url = '/admin/permissions-by-term/access-info-by-content-type/' + contentType;
13   }
14
15   return await fetch(url, { credentials:'include' })
16       .then(function(response) {
17         return response.json();
18       }).then(function(data) {
19         return data;
20       });
21 };
22
23 export default fetchFromBackend;