There is code for Vue 2 with Vuex 3.4:
getLink: (state, getters) => rel => {
let link = state.data?.getLinkWithRel(rel);
let stac = getters[rel];
let title = STAC.getDisplayTitle([stac, link]);
if (link) {
link = Object.assign({}, link);
link.title = title;
}
else if (stac instanceof STAC) {
return {
href: stac.getAbsoluteUrl(),
title,
rel
};
}
return link;
},
This code should be ported to Vue 3 with pinia. Did the following:
getLink: (state) => (rel) => {
let link = state.data?.getLinkWithRel(rel);
let stac = state[rel];
let title = STAC.getDisplayTitle([stac, link]);
if (link) {
link = { ...link };
link.title = title;
}
else if (stac instanceof STAC) {
return {
href: stac.getAbsoluteUrl(),
title,
rel
};
}
return link;
},
The stac variable contains either null or undefined values.
When using version 1, stac contains the data returned by the called getters[rel] function.
How do I write or force pinia to give data?
Additional information:
rel - contains a string with one of the getter names (parent or collection).
getter-parent:
parent: (state) => state.getStacFromLink('parent'),
Where getStacFromLink is also a getter.
getter-collection:
collection: (state) => state.getStacFromLink('collection'),
It looks like the parent or collection getters that are called do not get the state of the Store.