I'm trying to get some data from an array and store store it in an object but I keep getting either an empty object or Promise { <pending> }
in the logs. I'm using a global
variable to store it and access it in another function. Not sure what i'm doing wrong.
var messageData = {};
const getNotifications = async () => {
let fcmObjects = await fcmTokens();
fcmObjects.forEach( (notificationData) => {
messageData = notificationData;
});
};
function getMessageData() {
console.log(messageData);
}
getMessageData();
getNotifications().then(function () {
console.log('All Done');
}).catch(function (error) {
console.log('Oops', error);
});