Example of a Client Script that Calls a RESTlet

The following example shows how a client script can call a RESTlet. Because the client script is expected to have an active session, it uses a partial URL to call the RESTlet. That is, the URL does not have to include the RESTlet domain. You can find this partial URL in the URL field of the script deployment record for the RESTlet.

     /**

 * @NApiVersion 2.x

 * @NScriptType ClientScript

 */

define([‘N/https’], function(https) {

  return {

    pageInit : function() {

      var dataFromRestlet = https.get({

        url: ‘/app/site/hosting/restlet.nl?script=200&deploy=1’

      });

      console.log(dataFromRestlet.body);

    }

  }

}); 

     

Leave a comment

Your email address will not be published. Required fields are marked *