Invoke template in app.js

Hi Team,

We have facing a error is app.js code. how should we invoke the template for the app.js.

i have shared the code below for your reference.

  return new Promise(function (resolve, reject) {
    if (method == "GET") {
      var headers = { "Authorization": "Token token=<%= iparam.apiKey %>" };
      var options = { headers: headers, body: body };
      return fssClient.request.get(url, options).then(
        function (data) {
          resolve(data.response);
        },
        function (error) {

          reject(error);
        }
      )
    } else if (method == "POST") {

      var headers = { "Authorization": "Token token=<%= iparam.apiKey %>", "Content-Type": "application/json" };
      var options = { headers: headers, body: body };
      return fssClient.request.post(url, options).then(
        function (data) {

          resolve(data.response);
        },
        function (error) {

          reject(error);
        }
      )
    } else if (method == "POST-RECORDING") {
      var headers = { "Authorization": "Token token=<%= iparam.apiKey %>", "Content-Type": "multipart/form-data" };
      var options = { headers: headers, body: body };
      return fssClient.request.post(url, options).then(
        function (data) {

          resolve(data.response);
        },
        function (error) {

          reject(error);
        }
      )
    } else if (method == "PUT") {
      var headers = { "Authorization": "Token token=<%= iparam.apiKey %>", "Content-Type": "application/json" };
      var options = { headers: headers, body: body };
      return fssClient.request.put(url, options).then(
        function (data) {

          resolve(data.response);
          showNotify("Data Resolved","success")
        },
        function (error) {

          reject(error);
          showNotify("Data Rejected Notification","warning")

        }
      )
    } else {
      showNotify("Something went wrong with the communication to Freshsales Suite.", "warning");
    }
  });
}```

The code is in App.js file

Hi @bala

Please refer to the below link to get more insights.

https://developers.freshworks.com/docs/app-sdk/v2.3/freshsales-suite/advanced-interfaces/request-method/

Hope that helps, let me know otherwise :wink: .

Thank you.