Skip to content

Commit

Permalink
feat(cc): getBuddyAgents add more checks to KS
Browse files Browse the repository at this point in the history
  • Loading branch information
bhabalan committed Nov 12, 2024
1 parent a42f796 commit ee2ca21
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions docs/samples/contact-center/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,13 @@ async function fetchBuddyAgents() {
buddyAgentsDropdownElm.innerHTML = ''; // Clear previous options
const buddyAgentsResponse = await webex.cc.getBuddyAgents({mediaType: 'telephony'});

if (buddyAgentsResponse.data && buddyAgentsResponse.data.agentList.length === 0) {
if (!buddyAgentsResponse || !buddyAgentsResponse.data) {
console.error('Failed to fetch buddy agents');
buddyAgentsDropdownElm.innerHTML = `<option disabled="true">Failed to fetch buddy agents<option>`;
return;
}

if (buddyAgentsResponse.data.agentList.length === 0) {
console.log('The fetched buddy agents list was empty');
buddyAgentsDropdownElm.innerHTML = `<option disabled="true">No buddy agents available<option>`;
return;
Expand All @@ -203,7 +209,7 @@ async function fetchBuddyAgents() {
});

} catch (error) {
console.log('Failed to fetch buddy agents', error);
console.error('Failed to fetch buddy agents', error);
buddyAgentsDropdownElm.innerHTML = ''; // Clear previous options
buddyAgentsDropdownElm.innerHTML = `<option disabled="true">Failed to fetch buddy agents, ${error}<option>`;
}
Expand Down

0 comments on commit ee2ca21

Please sign in to comment.