Home > Blockchain >  Send multiple strings as separated values
Send multiple strings as separated values

Time:07-01

I want to make multiple emails as strings to be separated values. I'm trying something like this:

sendInquiry: function () {
                const id = '459875';
                const inquiry = {
                    to: '[email protected]' && '[email protected]',
                    senderEmail: this.form.email,
                    senderName: this.form.name,
                    subject: this.form.subject,
                    pN: this.form.personNum,
                    message: this.form.message
                };
}

What am I doing wrong? How to correctly send them ​​to be separated?

CodePudding user response:

'[email protected]' && '[email protected]' is interpreted as a boolean by javascript. Indeed, a no void string is true, so '[email protected]' && '[email protected]' is true.

To pass multiple strings the optimal data structure is an array, of course you can concat multiple strings into one (1) but it is easier to work with arrays because of the integrated methods builded in javascript.

Knowing that you should do :

sendInquiry: function () {
  const id = '459875';
  const inquiry = {
    to: ['[email protected]', '[email protected]'],
    senderEmail: this.form.email,
    senderName: this.form.name,
    subject: this.form.subject,
    pN: this.form.personNum,
    message: this.form.message
  };
}

(1) or use any other type of data

  • Related