Mobx Promise Solution?
I have a select query in a mobx store that looks like this:
getAllLegoParts = action("get all lego", () => {
this.legoParts = fromPromise(
fetch("http://localhost:8000/LegoPieces", {
cache: "no-store"
}).then(response => response.json())
);
});
this.legoParts is in the constructor, which looks like this:
constructor() {
extendObservable(this, {
// store
legoParts: fromPromise.resolve([]),
piece: "",
type: "",
startDate: "",
endDate: ""
});
}
I am trying to access the value of an array that should be in legoParts. However, when I console log legoParts, I get a bunch of data, including PromiseStatus (enabled) and PromiseValue. How can I just access the value of the promise? I am also confused because although PromiseStatus says it is allowed, the beginning of the object says
Promise{<pending>....
Thank you for your help!