@speakr/speakr-module-services
Version:
SPEAKR Shared Service Module
30 lines (26 loc) • 598 B
JavaScript
;
module.exports = {
publicData
};
function publicData(options) {
// 1. Get the agencies base object
let agencies = options.agencies;
// 2. Delete the options agencies
delete options.agencies;
// 3. Reset the options agencies
if (agencies.length >= 0) {
options.agencies = agencies.map(agency => {
return {
name: agency.name,
id_hash: agency.id_hash
}
})
} else {
options.agencies = {
name: agencies.name,
id_hash: agencies.id_hash
}
}
// 4. Return the options variable
return Promise.resolve(options);
}