Home > front end >  How to add a Line Break inside Message
How to add a Line Break inside Message

Time:01-05

How do I add a <br> to my message using node.js?

const Register = (req, res) => {
    const first_name = req.body.first_name
    const last_name = req.body.last_name
    const email = req.body.email
    const one_time_token = req.body.one_time_token

    return res.send({
        success: false,
        message: `<p><b>Generated Access Code:</b> ${one_time_token}</p>`
    })
}

Result:

Generated Access Code: XXXX-XXXXXX-XXXX

Expected:

line 1: Generated Access Code:
 line 2: XXXX-XXXXXX-XXXX 

CodePudding user response:

What do you mean by line break since you illustration of what you expect is the same as what you get ... But if you wish to have something like: Expected: Generated Access Code: (on one line) XXXX-XXXXXX-XXXX (on the next line) try using
tag

CodePudding user response:

Did you try to add the <br> HTML element in your message?

message: `<p><b>Generated Access Code:</b><br/>${one_time_token}</p>`
  • Related