REST API in ZC Widget

REST API in ZC Widget

Hi All,

How can i run REST API in Widget.

I have tried executing but an error is occurring.

I have attached screenshot of error too.

Here's the code:

  1. <html>
    <meta http-equiv="Content-Security-Policy" content="default-src * self blob: data: gap:; style-src * self 'unsafe-inline' blob: data: gap:; script-src * 'self' 'unsafe-eval' 'unsafe-inline' blob: data: gap:; object-src * 'self' blob: data: gap:; img-src * self 'unsafe-inline' blob: data: gap:; connect-src self * 'unsafe-inline' blob: data: gap:; frame-src * self blob: data: gap:;">
    <script src="js/jScript.js"></script>
    <script src="js/widgetsdk.js"></script>
    integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
    crossorigin="anonymous">
    </script>

    <script type='text/javascript'>
      var userEmail ;
      function loggedInUser(){
        refreshToken = "1000.5c6de3ee*********";
        clientID = "1000.FR9********";
        clientSecret = "89fe0a85c0*******";
        urlAccess = "https://accounts.zoho.in/oauth/v2/token?refresh_token=" + refreshToken + "&client_id=" + clientID + "&client_secret=" + clientSecret + "&grant_type=refresh_token";
        axios.post(urlAccess)
        .then(function (response) {
          console.log(response);
        })
        .catch(function (error) {
          console.log(error.data);
        });
      }

      function fetchInvoices(){
        ZOHO.CREATOR.init()
            .then(function(data) {
              //Code goes here
              var initparams = ZOHO.CREATOR.UTIL.getInitParams();
              let empCode;
              config = {
                appName : "sns",
                reportName : "All_Users",
                criteria: "(Email == \""+initparams['loginUser']+"\")",
              }
              ZOHO.CREATOR.API.getAllRecords(config).then(function(response){
                var recordEmp = response.data;
                empCode = recordEmp[0]['Emp_Code']
                var role = recordEmp[0]['Role']
                var hq = recordEmp[0]['HQ_Name']
                if(role === "Regional Sales Manager"){
                  filterHQ = "RSM_HQ"
                }
                configHQ = {
                  appName:"sns",
                  reportName:"HQ_Channel_Tree_Report",
                  criteria:"("+filterHQ+"==\""+hq+"\")",
                }
                ZOHO.CREATOR.API.getAllRecords(configHQ).then(function(responseHQ){
                  var recordHQ = responseHQ.data;
                 
                  for(var index in recordHQ){
                    console.log(recordHQ[index]);
                  }
                });
              });
              console.log(empCode);
            });
       
      }

      function multipleFunction(){
        loggedInUser();
        fetchInvoices();
      }

    </script>

    <head>
      <meta charset="UTF-8">
    </head>

    <body onload=multipleFunction()>
      <!-- <div class="screen-1">
        <img src="./images/gardeniaLogo.png">
        <div class="email">
          <label for="email">Logged In User</label>
          <div class="sec-2">
            <input type="email" name="email" id="loggedInUser" placeholder="Username@gmail.com" disabled/>
          </div>
        </div>
        <div class="empCode">
          <label for="empCode">Employee Code</label>
          <div class="sec-2">
            <input type="text" name="empCode" id="empCode" placeholder="GC1001"/>
          </div>
        </div>
        <button class="login" onclick=checkuserExists()>Login </button>
      </div> -->
    </body>

    </html>
Anyone know anything about this error. Please help.