admin管理员组文章数量:1296855
I define my sanity query like this. I inspected the network tab, and the response was correct. The first object printed is a RefImpl. It contains the correct values when I inspect it in the console. However when i try to acccess any of its fields later on, it does not work (last line). It has a correctly populated _value, _rawValue, and a value field. I get null when i try to access them.
const sizePickerQuery = groq`*[_id == "${props.data?._ref}"]`;
const { data: sizePickerData } = await useSanityQuery<SanityDocument[]>(sizePickerQuery);
console.dir(sizePickerData);
console.log(sizePickerData.value);
Any answers on how this could be done better in sanity are also appreciated.
I define my sanity query like this. I inspected the network tab, and the response was correct. The first object printed is a RefImpl. It contains the correct values when I inspect it in the console. However when i try to acccess any of its fields later on, it does not work (last line). It has a correctly populated _value, _rawValue, and a value field. I get null when i try to access them.
const sizePickerQuery = groq`*[_id == "${props.data?._ref}"]`;
const { data: sizePickerData } = await useSanityQuery<SanityDocument[]>(sizePickerQuery);
console.dir(sizePickerData);
console.log(sizePickerData.value);
Any answers on how this could be done better in sanity are also appreciated.
Share Improve this question asked Feb 11 at 18:47 Ola Hagen BendixenOla Hagen Bendixen 111 silver badge1 bronze badge1 Answer
Reset to default 1Simply had to do it another way in sanity. I requested the whole object instead of the reference. In the question i posted, i was trying to fetch the reference. That worked, but i could not access the value.
本文标签:
版权声明:本文标题:vue.js - Not able to access value, _value or _rawValue fields of a RefImpl from a sanity query in nuxt typescript - Stack Overfl 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741641081a2389920.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论