Invoking Function using API Call

A serverless function can be invoked as an API using HTTP post. The body of the API call is passed to the function as a parameter. Another serverless function can also invoke a serverless function. A serverless function can be long-running and suspend its execution while waiting for an external trigger. The execution of a serverless function can also be scheduled.

Shown below is a snippet of function invocation inside the frontend javascript. Here the "createPolicy" is the name of the function and URL for its invocation is "/function/quote/createPolicy" where "quote" is the name of application.

  BillingInfoC.doNext = function($e) {
    if (!this.view().canSubmit()) {
      return;
    }
    var pd = this.getParentData()
    var dt = this.getData();
    var body = $.extend({}, pd, dt);
    $.ajax({
      url: "/function/quote/createPolicy",
      type: 'post',
      data: Trillo.stringify(body),
      contentType: "application/json"
    }).done($.proxy(this.createPolicySucceeded, this, $e));
  };

Testing

While development, a function can be tested directly without the need for re-deployment. All you need is to make sure that function is deployed at once since creation. As a function may contact a service or data source, one must make sure that these services and data models are kept updated (using the deploy).