Skip to content

Throw error - TypeError: object is not iterable #2

@jignesht24

Description

@jignesht24

Hi

I am using this node in node--red but when I try to send email it throw error

TypeError: object is not iterable
at node:internal/deps/undici/undici:6155:39
at extractBody (node:internal/deps/undici/undici:6170:11)
at new Request (node:internal/deps/undici/undici:7114:48)
at new Ky (C:\Users\xxx.node-red\node_modules\mailgun.js\mailgun.node.js:2:60421)
at t (C:\Users\xxx.node-red\node_modules\mailgun.js\mailgun.node.js:2:64310)
at e. (C:\Users\xxx.node-red\node_modules\mailgun.js\mailgun.node.js:2:35504)
at C:\Users\xxx.node-red\node_modules\mailgun.js\mailgun.node.js:2:34536
at Object.next (C:\Users\xxx.node-red\node_modules\mailgun.js\mailgun.node.js:2:34641)
at C:\Users\xxx.node-red\node_modules\mailgun.js\mailgun.node.js:2:33553

I have tried to use following Nodejs code and run in local machine, it is sending an email.

const API_KEY = 'YOUR_API_KEY';
const DOMAIN = 'YOUR_DOMAIN_NAME';

import formData from 'form-data';
import Mailgun from 'mailgun.js';

const mailgun = new Mailgun(formData);
const client = mailgun.client({username: 'api', key: API_KEY});

const messageData = {
from: 'Excited User me@samples.mailgun.org',
to: 'foo@example.com, bar@example.com',
subject: 'Hello',
text: 'Testing some Mailgun awesomeness!'
};

client.messages.create(DOMAIN, messageData)
.then((res) => {
console.log(res);
})
.catch((err) => {
console.error(err);
});

Can you please help here?

I am using Node-RED version: v3.1.3, Node.js version: v19.4.0

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