admin管理员组文章数量:1424977
I am using mailchimp-api-v3 to submit a form.
This list only has three fields, which are FNAME
, EMAIL
, and COMPANY
.
const Mailchimp = require('mailchimp-api-v3');
const mailchimp = new Mailchimp(myMailchimpAPI);
mailchimp.post(`/lists/${myListId}/members`, {
FNAME: 'Jack',
EMAIL: '[email protected]',
COMPANY: 'Apple'
})
.then(res => console.log(res))
.catch(err => console.log(err));
This gives me error:
[ { field: 'email_address', message: 'This value should not be blank.' } ] }
I am using mailchimp-api-v3 to submit a form.
This list only has three fields, which are FNAME
, EMAIL
, and COMPANY
.
const Mailchimp = require('mailchimp-api-v3');
const mailchimp = new Mailchimp(myMailchimpAPI);
mailchimp.post(`/lists/${myListId}/members`, {
FNAME: 'Jack',
EMAIL: '[email protected]',
COMPANY: 'Apple'
})
.then(res => console.log(res))
.catch(err => console.log(err));
This gives me error:
Share Improve this question edited Dec 30, 2022 at 2:44 Hongbo Miao asked Jan 16, 2019 at 20:33 Hongbo MiaoHongbo Miao 50.3k67 gold badges203 silver badges329 bronze badges[ { field: 'email_address', message: 'This value should not be blank.' } ] }
1 Answer
Reset to default 7I figured out after reading the Mailchimp API document.
I have to add another two fields email_address
and status
which are required. Then move the rest of form fields under merge_fields
.
The correct code is
const Mailchimp = require('mailchimp-api-v3');
const mailchimp = new Mailchimp(myMailchimpAPI);
mailchimp.post(`/lists/${myListId}/members`, {
email_address: '[email protected]',
status: 'subscribed',
merge_fields: {
FNAME: 'Jack',
EMAIL: '[email protected]',
COMPANY: 'Apple'
}
})
.then(res => console.log(res))
.catch(err => console.log(err));
It was hard for me to find a simple demo online. Hope this helps for future people.
本文标签: javascriptHow to submit a form (add a subscriber) by mailchimpapiv3 in NodejsStack Overflow
版权声明:本文标题:javascript - How to submit a form (add a subscriber) by mailchimp-api-v3 in Node.js? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745421704a2657928.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论