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.

Note:

The partial URL in this example is a placeholder. Before using this script, replace this string with a valid value from your NetSuite account.

          /**
 * @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);
        }
    }
}); 

        

Related Topics

General Notices