Querying for Badges in a Group
Once you have the earner's Backpack user ID and the IDs for any groups you are interested in, you can make a request that will provide you with the earner's awarded badges within each specified group.
var Openbadges = require('machinepack-openbadges');
// Querying for Badges in a Group
Openbadges.getBadges({
uid: 125363,
gid: 67890,
}).exec({
// An unexpected error occurred.
error: function (err) {
},
// Could not find a badges.
badgesNotFound: function (result) {
},
// OK.
success: function (result) {
},
});
Backpack user ID
125363
group ID
67890
An unexpected error occurred.
Could not find a badges.
{
status: 404,
headers: '{"Accepts":"application/json"}',
body: '{"httpStatus":404,"status":"missing"}'
}
OK.
{
status: 200,
headers: '{"Accepts":"application/json"}',
body: '{"userId":125363,"groupId":45690,"badges":[]}'
}