Skip to content

Unable to validate replyTo field without using the EmailAddress class #15

@edpei

Description

@edpei

From the documentation examples:

//Many different ways to add recipients
message.to.push("recipient1@example.com");
message.to.push(new EmailAddress("recipient2@example.com"));
message.to.push(new EmailAddress("recipient3@example.com", { friendlyName: "Recipient #3" }));
message.to.push({ emailAddress: "recipient4@example.com" });
message.to.push({ emailAddress: "recipient5@example.com", friendlyName: "Recipient #5" });

i understand that for every email i have these many options to use, but for the given case of the replyTo field if i try to use the object definition directly:
replyTo: { emailAddress: data.replyTo.emailAddress }

it throws the following error:

2022-05-27T09:48:39.363Z	bee95426-8d19-5c27-b788-0f2c2db3636d	ERROR	Invoke Error 	{"errorType":"TypeError","errorMessage":"this.replyTo.toJSON is not a function","stack":["TypeError: this.replyTo.toJSON is not a function","    at e.exports.toJSON (/var/task/src/main/js/index.js:2:18636)","    at /var/task/src/main/js/index.js:2:3417","    at new Promise (<anonymous>)","    at Object.generateRequest (/var/task/src/main/js/index.js:2:2703)","    at /var/task/src/main/js/index.js:2:34672","    at new Promise (<anonymous>)","    at SocketLabsClient.send (/var/task/src/main/js/index.js:2:34552)","    at /var/task/src/main/js/index.js:2:473415","    at processTicksAndRejections (internal/process/task_queues.js:95:5)","    at async Runtime.e.exports.handler (/var/task/src/main/js/index.js:2:471749)"]}

I had to import the EmailAddress class to avoid the error. I believe since the documentation states that the declaration can be done differently there's something to be addressed.

Thanks

PD: i have other emails in the message other than the replyTo declared the same way and they work properly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions