FreshDesk App initialisation issue

Hi team,

We have a custom FD app built in house to assist our needs, the application seems to be glitching, the problem we are facing is that the app.initialized() is not getting called and the client is not available for us to fetch data from.

document.addEventListener("DOMContentLoaded", () => init());

async function init() {
  app
    .initialized()
    .then(function (_client) {
      window.client = _client;
      client.events.on("app.activated", showUI);
    })
    .catch(function (error) {
      showError("Unable to get FD client");
      console.error(error);
    });
}

Below is the head section of index.html

<head>
  <title>Support HQ</title>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <script src="https://static.freshdev.io/fdk/2.0/assets/fresh_client.js"></script>
  <script async src="{{{appclient}}}"></script>
  <link rel="stylesheet" type="text/css" href="styles/style.css" />
  <script async type="module" src="https://unpkg.com/@freshworks/crayons@3/dist/crayons/crayons.esm.js"></script>
  <script async nomodule src="https://unpkg.com/@freshworks/crayons@3/dist/crayons/crayons.js"></script>
  <script src="scripts/app.js"></script>
</head>

Hi @Suyash_Sonawane,

Welcome to the community :tada:

Please refer to the sample apps repo below, where you can find different applications with different placeholders. And also check this repo too

Hope that helps!

Let me know otherwise :+1:

Thank you :smiling_face:

We are following the similar approach as

But the promise doesn’t get resolved

Hi @Suyash_Sonawane,

Greetings!

Could you try with the Promise(refer to the code below).

const onAppInitializedCallback = (_client) => {
	window.client = _client
}

app.initialized()
	.then(onAppInitializedCallback)
	.catch(() => {
		console.log("oops!")
	})

Because I have experienced issues with await in FS in the past. Getting the client in a callback fixed the issue for me.

Let’s hope the same :crossed_fingers:

Thank you.