Join us live Sept. 27 – How Sanity and Vercel powered Morning Brew's transformation –>

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: Get the most out of your content

Sanity.io is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Give your team exactly what they need to edit and publish their content with the customizable Sanity Studio. Get real-time collaboration out of the box. Sanity.io comes with a hosted datastore for JSON documents, query languages like GROQ and GraphQL, CDNs, on-demand asset transformations, presentation agnostic rich text, plugins, and much more.

Don't compromise on developer experience. Join thousands of developers and trusted companies and power your content with Sanity.io. Free to get started, pay-as-you-go on all plans.