Hello!
I’m trying to get data from a JSON which contains a series of events (objects) assigned by a fetch function.
var MyEvents = Observable();
...
EventContext.getEvents(ThisUser.id, "mine").then(function(Events) {
MyEvents.value = Events;
};
Inside the returned promise, the Events variable returned is working perfectly:
console.log("First event name: " + Events[0].name);
//Prints "First event name: Party again"
While assigning Events to the MyEvents observable doesn’t seem to work. It doesn’t print anything at all, not even "First event name: "…
However, it does seem to be assigned something when printing the whole array by itself:
console.log("MyEvents: " + MyEvents);
//Prints "MyEvents: (observable) [object Object],[object Object],[object Object],[object Object]"
Then if I try to print first index of MyEvents:
console.log("MyEvents: " + MyEvents[0]);
//Prints "MyEvents: undefined"
Doing this:
<Each Items="{MyEvents}">
<MyEventCard />
</Each>
Does not seem to do the trick either as it only spits out a single blank EventCard.
What is happening here? My understanding is that there should not be any difference in syntax between the two. Or am I missing something?
Thank you in advance!