TBD
Explain how to configure the “target server” if teh script is loaded from a location other than the backend application. This will be the case with the locally stored scripts.
Describe the method parameters
Here is a list of samples.
$app.restful({
url: products._links.self,
accept: 'text/yaml',
hypermedia: false
}).then(yaml => {
alert(yaml)
});
return;
// export the output in CSV format
$app.restful({
url: apiHypermedia.products._links.self, // (1) products._links.self // (2) "/v2/suppliers",
accept: 'text/csv'
}).then(blob => {
let dataUrl = URL.createObjectURL(blob);
let a = document.createElement('a');
a.setAttribute('download', blob.name);
a.setAttribute('href', dataUrl);
a.click();
URL.revokeObjectURL(dataUrl);
});
return;
// download a picture in BLOB format - show how to assign it to an element
$app.restful({
url: "/v2/categories/195/picture"
}).then(blob => {
let dataUrl = URL.createObjectURL(blob);
let a = document.createElement('a');
a.setAttribute('download', blob.name);
a.setAttribute('href', dataUrl);
a.click();
URL.revokeObjectURL(dataUrl);
});