👀 See Sanity in action: Watch product demo now →

Anyone who could help me out with sanity/mux?

5 replies
Last updated: Nov 3, 2020
Anyone who could help me out with sanity/mux? I’m new to sanity and mux, and I want to be able to upload videos in sanity using mux, this integration for studio was easy. However, when I’m trying to fetch the video for web, I get this:
video: { asset: { _ref: '6c100819-3c4b-4c80-9077-3219a7ccb35e' } }
The ref is the same as the videos passthrough property. I dont get any other data on the asset (preferably I want the id).
In my schema I’ve added it like this (to a post consisting of some additional fields such as text, images etc.):

{
  name: 'video',
  type: 'mux.video',
}
And my query is currently super simple:

groq`*[_type == "post"]`

Nov 3, 2020, 10:41 AM
The
asset
field is presumably a reference to an asset, and not an asset by itself, so it has to be dereferenced/expanded in the query https://www.sanity.io/docs/how-queries-work#expanding-references-8ca3cefc3a31
Nov 3, 2020, 10:50 AM
Thanks, yes I looked through that. However, I don’t understand how I can use that reference to get the videos Id. I have tried following the tutorial of sanity + mux with the request posted there, however the response is still the same:
video: { asset: { _ref: '6c100819-3c4b-4c80-9077-3219a7ccb35e' } }
Nov 3, 2020, 11:09 AM
Its solved, added to query
"video": video.asset->
Nov 3, 2020, 11:43 AM
Glad you got help with that! Let me know if we can help with anything else!
Nov 3, 2020, 3:51 PM

Sanity.io – build remarkable experiences at scale

Sanity is a customizable solution that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.