We can call rest API configured in service connection using RestHelper
The function getLineItems() can be called using action chain.
define(["vb/helpers/rest"], (Rest) => {
"use strict";
class PageModule {
getLineItems() {
let endpointurl = "buinessObjects/getalls_Country";
let queryString = "id is not null";
return new Promise(function (resolve, reject) {
var ep = Rest.get(endpointurl);
ep.parameters({
q: queryString,
onlyData: true,
limit: 50,
orderBy: "id:asc",
});
ep.fetch().then(function (result) {
if (result.response.ok) {
resolve(result.body.items);
} else {
resolve([]);
}
});
});
}
}
return PageModule;
});
We can call the rest API configured in the service connection using Rest Helper in APP UI as well
We have to additional pass extensionId – site_MyExtension. ( id of the APP UI extension.
You can find the extension id from ->
- Open workspace, click on extension name in left hand side
- Go to settings and you will find extension id.
define(["vb/helpers/rest"], (Rest) => {
"use strict";
class PageModule {
getLineItems() {
let extensionId = "site_MyExtension"
let endpointurl = "site_MyExtension:saasRestApi/getalls_Country";
let queryString = "id is not null";
return new Promise(function (resolve, reject) {
var ep = Rest.get(endpointurl, { extensionId: "site_MyExtension" } );
ep.parameters({
q: queryString,
onlyData: true,
limit: 50,
orderBy: "id:asc",
});
ep.fetch().then(function (result) {
if (result.response.ok) {
resolve(result.body.items);
} else {
resolve([]);
}
});
});
}
}
return PageModule;
});