Hi guys, I’ve followed the instructions on the forum on how to pass data from wix dataset (forms) to mailchimp api however I have an issue. What could be the solution here? Thx
Here is the problem I currently have when I try to pass the request from wix preview:
– Hook afterInsert for collection LeadGeneration result ignored! Expected hook result to resolve to an object with an ‘_id’ property, but got [Undefined] –
Here is the page code:
import {sendToMailChimp} from ‘backend/mailChimp.jsw’;
export function LeadGeneration_afterInsert() {
var data = {
“email_address”:$w(“#input3”).value,
“merge_fields”: {
“FNAME”:$w(“#input1”).value,
“LNAME”:$w(“#input2”).value
//“PHONE”:$w(“#input3”).value
},
“status”:“subscribed”
};
data = JSON.stringify(data, ‘\t’);
sendToMailChimp(data);
console.log("API Test");
}
Here the backend code:
// Filename: backend/mailChimp.jsw (web modules need to have a .jsw extension)
Have you checked your MailChimp list? Sometimes it works but the editor throws the above warning.
Your code looks fine. Although the base URL https://us20.api.mailchimp.com differs for each person. You should check your own MC dashboard if the url is same or not.
Another thing, hope this is not the actual API Key and LIST ID that you have posted. If it is then there is a problem with your API Key (and remove it from your post)
Hi, thx. I just realized I posted my api key removed.
I was checking in parallel with mailchimp list and there wasn’t any update there. Not sure what is the issue. I’ve checked the API calls on MC side and the list is empty. The base URL starts with us20 on my dashboard.
@vuuuk81 I have tested the following code and it works. I just added a console.log() and return to the frontend/backend so that the response from the api gets printed.