Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit 1ccab39

Browse files
author
Wardormeur
committed
Ensure we dont crash on unexpected scenarios
1 parent 1391ee8 commit 1ccab39

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

lib/export-guest-list.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ function exportGuestList (args, callback) {
3939
application.userProfile = userProfile;
4040
seneca.act({ role: 'cd-profiles', cmd: 'load_parents_for_user', userId: userProfile.userId, user: args.user }, function (err, parentProfile) {
4141
if (err) callback(err);
42-
const firstParent = parentProfile[0];
43-
application.userProfile.email = firstParent.email;
44-
application.userProfile.phone = application.userProfile.phone || firstParent.phone;
42+
if (parentProfile.length > 0) {
43+
const firstParent = parentProfile[0];
44+
application.userProfile.email = firstParent.email;
45+
application.userProfile.phone = application.userProfile.phone || firstParent.phone;
46+
}
4547
cb(null, application);
4648
});
4749
} else {

0 commit comments

Comments
 (0)