//*---------------------------------------------------------------------------------------
Enumerate files within a given root folder with authentication enabled */
let basePrintPortalURL = "https://example.com/Bartender/";
let route = "libraries/";
let token = "token_value_from_authentication_call";
fetch(basePrintPortalURL + route, {
method: 'get',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + token
},
})
.then(response => response.json())
.then(result => {
console.log(result);
// In case of multiple libraries, the following will display each library ID individually
for (const library of result)
{
// Displays the libraryID(s), the ID can be used in another request to gather information about an individual library
console.log(library.id);
// Displays the name(s) of each library
console.log(library.name);
// Displays the relative path of each library
console.log(library.relativePath);
}
// Displays the specific error message in case of a failed request
console.log(result.errors.id);
// Displays the title of the error message
console.log(result.title);
// Displays the error message status code
console.log(result.status);
})
.catch(error => {
console.error('There has been a problem with your fetch operation: ', error.message);
});