Front-End API Instructions

Caution: This guide is for people who have JavaScript experience

This article will cover two topics

Accessing member information with JS
Updating and retrieving member metadata.

How to access member information with JS

MemberStack.onReady.then(function(member) {
// do things with the member object
console.log(member["email"])
console.log(member["name"])

// check if member is logged in
member.loggedIn // returns true or false
})


You have access to any fields you collect during signup, just like you do when using ms-data.

Updating and retrieving member metadata

MemberStack allows you to extend its functionality through member metadata. You have the ability to update and access metadata that you can store with each Member

Metadata must be valid JSON

Updating

To set/update metadata use the updateMetaData member function.

MemberStack.onReady.then(function(member) {
var memberProgress = {
lesson1: "finished",
lesson2: "in-progress"
}
member.updateMetaData(memberProgress)
})

You can update a single property without affecting others.

lesson1 data will not be changed

MemberStack.onReady.then(function(member) {
var memberProgress = {
lesson2: "finished"
}
member.updateMetaData(memberProgress)
})


You can remove properties by setting their value to null

lesson1 and lesson2 data will removed

MemberStack.onReady.then(function(member) {
var memberProgress = {
lesson1: null,
lesson2: null
}
member.updateMetaData(memberProgress)
})


Retrieving

MemberStack.onReady.then(async function(member) {
var metadata = await member.getMetaData()
// do stuff with members data
})
Was this article helpful?
Cancel
Thank you!