Skip to content

Commit 05155e9

Browse files
authored
Merge pull request #32 from usabilla/fix-example
chore(example): fix undefined cases in example
2 parents cd2c820 + a6ff640 commit 05155e9

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

example/example.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,15 @@ const usabilla = new Usabilla(args[0], args[1]);
1010
// Get all buttons for this account.
1111
usabilla.websites.buttons.get().then((buttons) => {
1212

13+
const button = buttons[1];
14+
15+
if (!button) {
16+
return;
17+
}
18+
1319
// Use the button id to get feedback for this button id.
1420
let buttonFeedbackQuery = {
15-
id: buttons[0].id,
21+
id: button.id,
1622
params: {
1723
limit: 10
1824
}
@@ -30,9 +36,15 @@ usabilla.websites.buttons.get().then((buttons) => {
3036
// Get all campaigns for this account.
3137
usabilla.websites.campaigns.get().then((campaigns) => {
3238

39+
const campaign = campaigns[0];
40+
41+
if (!campaign) {
42+
return;
43+
}
44+
3345
// Get the results for a campaign with id.
3446
let campaignQuery = {
35-
id: campaigns[0].id
47+
id: campaign.id
3648
};
3749

3850
// Get the responses of the first campaign
@@ -86,9 +98,15 @@ usabilla.email.widgets.get().then((emailWidgets) => {
8698
// Get all apps forms for this account.
8799
usabilla.apps.forms.get().then((appsForms) => {
88100

101+
const appsForm = appsForms[1];
102+
103+
if (!appsForm) {
104+
return;
105+
}
106+
89107
// Get the feedback for a apps form with id.
90108
let appsQuery = {
91-
id: appsForms[1].id
109+
id: appsForm.id
92110
};
93111

94112
// Get the feedback of the second app form

0 commit comments

Comments
 (0)