Class

RestServices

RestServices()

Helper class for Rest services.
Provides methods such as for making HTTP API calls.

Constructor

# new RestServices()

View Source tools/RestServices.js, line 57

Classes

RestServices

Members

# readonly METHODS

Supported HTTP methods.
GET / POST / PUT / DELETE / PATCH

View Source tools/RestServices.js, line 72

Example
// call REST service
   const url = `${ctx.getServiceUrl(InfohubContext.SERVICE.USR)}/${cntx.getScope()}/usergroups?filter=$userid ~eq~ '${userid}'&members=info`;
   let resp = RestServices.makeApiCall( ctx.getToken(), RestServices.METHODS.GET , url);
   

Methods

# async static makeApiCall(token, method, fullpath, body, acceptType, contentType, responseType) → {Promise.<RestResponse>}

Make HTTP API call. Uses 'fetch' to execute the call.

Parameters:
Name Type Default Description
token string

The access token to use for the API call

method string

HTTP method

fullpath string

URL of endpoint

body Object null

= null, Request Body, Could be null for GET

acceptType string application/json

= "application/json", Accept: acceptType // Accept Header

contentType string application/json

= "application/json" Content-Type header

responseType string auto

"auto" // "auto" | "json" | "text" | "blob" | "arrayBuffer" Response type

View Source tools/RestServices.js, line 105

Promise.<RestResponse>
Example
//
 const url = `${ctx.getServiceUrl(InfohubContext.SERVICE.USR)}/${ctx.getScope()}/usergroups?filter=$userid ~eq~ '${userid}'&members=info`;
 let resp = RestServices.makeApiCall( ctx.getToken(), RestServices.METHODS.GET , url);