【发布时间】:2020-05-21 19:49:14
【问题描述】:
我正在尝试将新用户添加到 Mailchimp 活动。我收到两个错误,第一个说:
Function returned undefined, expected Promise or value
第二个错误的日志是:
Error: The resource submitted could not be validated. For field-specific details, see the 'errors' array.
type: 'http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/',
title: 'Invalid Resource',
status: 400,
detail: 'The resource submitted could not be validated. For field-specific details, see the \'errors\' array.',
instance: '549e8553-5ef1-4600-9271-07255f4673fe',
errors:
[ { field: 'status',
message: 'The value you selected is not a valid choice.' } ] }
这是我的功能
exports.userCreated = functions.auth.user().onCreate((user) => {
const email = user.email;
// const displayName = user.name;
// make Mailchimp API request to add a user
Mailchimp
.post('/lists/id/members', {
email_address: email,
status: 'Signed Up',
// optional: requires additional setup
merge_fields: {
"EMAIL" : email
}
})
.then(function(results) {
console.log('Successfully added new Firebase user', email, 'to Mailchimp list',results);
})
.catch(function(err) {
console.log(email);
console.log('Mailchimp: Error while attempting to add registered subscriber —', err);
});
});
【问题讨论】:
标签: javascript node.js firebase google-cloud-functions mailchimp