MemberStack.io

Overwriting metadata via JSON

I am having trouble getting Memberstack to overwrite a JSON string, even though console shows the data being passed correctly. Here is my code:

<script>
// Validate User Progress //

// Set Variables //
var startDate = new Date();
// End set variqables. //

// Check initiated state. //
MemberStack.onReady.then(async function(member) {
  var metadata = await member.getMetaData()

  if (metadata.initiated === "Y") {
    runTimer();
  } else {
    var sDobj = {
      startDate: startDate,
    }
    var initY = {
      initiated: "Y"
    }
    var sDobjjson = JSON.stringify(sDobj);
    var initYjson = JSON.stringify(initY);
    member.updateMetaData(sDobj, initY)
  }

})
// End check initiated state. //

// Run timer. //
function runTimer() {
  alert('runTimer activated');
}
// End run timer. //
</script>

Here is a screengrab of console showing it working as expected:

The problem here is that the function member.updateMetaData(sDobj, initY) is passing down the correct start date but not the correct initiated string value. What I believe is happening here is that when I am getting the metadata with var metadata = await member.getMetaData() it returns initiated = "N" as the default state as it is undefined (correct).

But then it isn’t overriding it when the value is redefined in the else statement and the string is sent back.

Anyone got any ideas why this is happening or know a way around it?