How to troubleshoot 'MemberStack is not defined' error in Webflow custom JavaScript code? Answered
I’m using ChatGPT and it’s almost there, but keeps returning this error:
Uncaught ReferenceError: MemberStack is not defined at HTMLImageElement.
I’m using ChatGPT and it’s almost there, but keeps returning this error:
Uncaught ReferenceError: MemberStack is not defined at HTMLImageElement.
Comments
4 comments
can you give us your entire code snippet?
document.getElementById("save-button").addEventListener("click", function() {// Retrieve the current member's data using Memberstack's getCurrentMember method
memberstack.getCurrentMember().then(function(member) {
console.log("Memberstack getCurrentMember response:", member);
// Retrieve the current webflow page ID
var pageId = window.location.pathname;
// Create a payload object with the member's data and page ID
var payload = {
memberData: member.data,
pageId: pageId
};
console.log("Payload:", payload);
// Send the payload to the webhook URL endpoint using a POST request
fetch("https://hook.us1.make.com/n5ww9smmb4i9p579babovkpsrdwpdrfs", {
method: "POST",
body: JSON.stringify(payload),
headers: {
"Content-Type": "application/json"
}
}).then(function(response) {
// Handle the response from the webhook endpoint
console.log("Webhook response:", response);
return response.json();
}).then(function(data) {
console.log("Webhook data:", data);
}).catch(function(error) {
// Handle any errors that occur during the fetch request
console.error("Webhook error:", error);
});
}).catch(function(error) {
// Handle any errors that occur during the getCurrentMember request
console.error("Memberstack getCurrentMember error:", error);
});
});
the 3rd line from the top, change memberstack.getCurrentMember().then... to window.$memberstackDom.getCurrentMember().then
I’ll give it a try!
HEy!!! IT WORKED ♥️
Please sign in to leave a comment.