ZAFClient initializes to false when init called
Posted Mar 31, 2023
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
0
1
0 comments
Sign in to leave a comment.