ZAFClient initializes to false when init called
I have a top bar application, which has a requirement to set the requester information as soon as some calls come in or outbound call is made, after searching for user based on the phone number. The application is based on react . Here is code snippet.
This code is in main.js
import {setupClient} from './zafClient2';
const initClient = async () => {
await setupClient();
console.log(window.ZAFClient.init());
};
initClient();
The zafClient2.js code is below here
export const setupClient = async () => (
new Promise((res, rej) => {
const script = document.createElement('script');
script.type = 'module';
script.src = 'https://static.zdassets.com/zendesk_app_framework_sdk/2.0/zaf_sdk.min.js';
script.crossOrigin = '';
script.onload = () => {
res("Success");
};
document.body.appendChild(script);
})
)
The real challenge happens in home page where i need to use the
code
const initClient = async () => {
await setupClient();
const client = window.ZAFClient.init();
console.log({client});
}
The console prints false for client and hence unable to call any API
-
Hi Dinesh,
This will happen in server-side apps when theapp_guid
andorigin
ZAF parameters are not included in the URL. They are necessary for the ZAF SDK to be able to interact with ZAF. For a more detailed breakdown of this, check out Accessing framework APIs in our Building a server-side app tutorial.
Please sign in to leave a comment.
1 Comments