I'm attempting to send an email that includes a link with a value obtained from Firebase. While I can successfully retrieve the value, I am unsure how to add it to the existing link. Here is my code snippet:
sendinvite() {
var user = firebase.auth().currentUser;
var uid = user.uid;
firebase.database().ref('/userlist/' + uid + '/' + 'hashKey').once('value').then(function(snapshot) {
var hashKey = (snapshot.val());
console.log(hashKey)
});
var bcc = [];
for(var e in this.emailinputs){
if (this.emailinputs[e].email==null || this.emailinputs[e].email=="" || !this.emailinputs[e].email.includes("@") || !this.emailinputs[e].email.includes("."))
{
let alert = this.alerCtrl.create({
title: 'Error!',
message: 'There was an error with an email address you entered.',
buttons: ['Ok']
});
alert.present()
}else {
bcc.push(this.emailinputs[e].email);
}
}
if(bcc.length > 0) {
let email = {
bcc: bcc,
subject: 'Nudget Invite',
body: '<a href="https://nudget-72ee4.firebaseapp.com/?hashkey='+hashKey+'">Join my grocery list!</a>',
isHtml: true
};
this.emailComposer.open(email);
}
}
I aim to include the hashKey
variable in the URL attached in the email message but need guidance on how to accomplish this.
Edit 1
I have modified the body section to combine the variable with the string. However, I am unsure where to appropriately integrate the hashkey retrieved from Firebase for proper referencing.