I am trying to create a service where an email is sent after an http request is made. I have several variables defined within the text of the document, something like #FIRSTNAME
#LASTNAME
etc. and after an even I want to replace these with information received by the post (i.e. dynamically and not prior known variables).
The current method I am using involved a regex method of
matcha = /#FIRSTNAME/
matchb = /#LASTNAME/
But after only those two emails I have a pretty long code string that looks like:
let outgoingEmail = data.replace(matcha, vara).replace(matchb, varb)
Is there a more concise way to replace several matches or do I have to just chain all of the matches together?
With two I guess this is tolerable but I would like to replace many and I am wondering how things like email templating services typically handle this.