Can I call routes in a RESTApp from a Script or a WebApp?

Yes, RestAppInvokerFactory is the starting point to make calls to a RESTApp without any outgoing requests

RespAppInvokerFactory make it possible to make call routes in a WebbApp from a Script module.

Step 1 - Get an instance of RestAppInvokerFactory

For WebApp/RESTApp 2; use import:

import restAppInvokerFactory from '@sitevision/api/server/RestAppInvokerFactory';

For Script module and WebApp/RESTApp 1; use require:

const restAppInvokerFactory = require('RestAppInvokerFactory');

Step 2 - Make use of tRestAppInvokerFactory

// The RESTApp can be found by identifier, node or as in this case the path
const restApp = restAppInvokerFactory.fromPath('/rest-api/MyRestApp');

// The route is called (get, post, put or delete) and can be called with or without input data
const response = restApp.get('/routeName');

// response is a script object representing the response (properties: headers, statusCode, statusMessage, body)
if (response.statusCode !== 200) {
  // Handle error and return

// The body of the response contains the actual data
const body = response.body;

Do you want to subscribe to News from Sitevision Developer team? Subscribe here!