Skip to content

Commit

Permalink
fix: api does not save undefined fields
Browse files Browse the repository at this point in the history
  • Loading branch information
nomadbitcoin committed Sep 25, 2024
1 parent cc50400 commit 0d3bbd3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion functions/lib/mailchimp.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ exports.addUserToList = async function (emailData) {
}

exports.createUser = async function (user) {
console.log('Saving user on mailchimp...', user)
try {
const result = await mailchimp.lists.addListMember('b578d43584', {
email_address: user.email,
status: 'subscribed',
merge_fields: { WALLET: user.wallet_address, NAME: user.name },
merge_fields: {
WALLET: user.wallet_address || '',
NAME: user.name || '',
},
})
console.log('User added to Mailchimp successfully:')
} catch (error) {
Expand Down

0 comments on commit 0d3bbd3

Please sign in to comment.