To convert an earner email address to Backpack user ID
You can make a REST API request to the convert service in the Mozilla Backpack to convert an earner email to their user ID, which you can then use in your calls to the Displayer API.
var Openbadges = require('machinepack-openbadges');
// To convert an earner email address to Backpack user ID
Openbadges.convertEmail({
emailAddress: '[email protected]',
}).exec({
// An unexpected error occurred.
error: function (err) {
},
// Could not find a user by the email address `[email protected]`
mailNotFound: function (result) {
},
// OK.
success: function (result) {
},
});
An email address.
'[email protected]'
An unexpected error occurred.
Could not find a user by the email address `[email protected]`
{
status: 404,
headers: '{"Accepts":"application/json"}',
body: '{"status":"missing","error":"Could not find a user by the email address `[email protected]`"}'
}
OK.
{
status: 200,
headers: '{"Accepts":"application/json"}',
body: '{"status":"okay","email":"[email protected]","userId":125363}'
}