I’m hoping my problem is going to be another “Doh!” experience. I’ve written a backend function to retrieve the current member details and if the member holds a certain badge. It should be so straightforward to an extra field to returned object but I just can’t figure out the correct format!
It’s line 8 and I’ve currently got member [ ‘permission’ ]= checkBadge ([ member . _id ,]);
but it isn’t working.
Can anyone explain what I’m doing wrong?
Thanks
export function getCurrentMember ( ) {
let options = {
fieldsets : [ ‘FULL’ ],
}
return currentMember . getMember ( options )
. then (( member ) => {
member [ ‘permission’ ]= checkBadge ([ member . _id ,]);
return member ;
})
. catch (( error ) => {
console . error ( error );
})
}
function checkBadge ( members ) {
let matchesBadge = false ;
return badges . listMemberBadges ( members )
. then (( allBadges ) => {
if ( allBadges . length > 0 ) {
matchesBadge =( allBadges [ 0 ]. badgeIds . find ( matchBadge ) !== “undefined” );
}
return matchesBadge ;
})
. catch (( error ) => {
console . error ( error );
})
}
function matchBadge ( badge ) {
const badgeId = ‘f269cc69-9362-4736-aed2-78841ba33c52’ ;
return badge == badgeId ;
}