j roc
j roc

Reputation: 238

Setting a href inside of template literals

I'm trying to make use of a nice email template for when a user signs up with their email, I'm using express & node mailer to accomplish this. Previously my code looked like:

"Hello, " +
 user.username +
 ",\n\n" +
"Please complete your registration by clicking the link:
 \nhttp://" + req.headers.host + "/confirmation/" + user.username + "/" + token.token +
"\n\nThank you!\n"

Inside of my HTML template, which is a template literal ive tried this:

const output = ` <a href="${req.headers.host} + "/confirmation/" + ${user.username} + "/" + ${token.token}"  `

but this doesn't work, theres no href on the <a> inside of the email.

I must be missing something really basic... thanks for looking =)

Upvotes: 0

Views: 2356

Answers (1)

Velrin Black
Velrin Black

Reputation: 412

With `` you don't need to concatenate the string with +, so it should look like this:

const output = `<a href="${req.headers.host}/confirmation/${user.username}/${token.token}"></a>`

Upvotes: 3

Related Questions