Go Behind the Experience to see how Tecovas brings the West to life with Sanity 🤠 July 18th

Oliver seeks help with fetching query content in descending order from release number in Sanity.

17 replies
Last updated: Aug 5, 2022
So I am still pretty new to sanity and I was trying to fetch query content from the release number descending, when I fetch it in the vision section it seems to do it fine but when I try fetch it in js it doesnt seem to show up like that on the site?
Aug 5, 2022, 8:27 PM
Hey Oliver. Could you please group all your messages so we use a single thread?
Aug 5, 2022, 8:34 PM
user S
please group your question in a single thread so that we can keep track of all relevant information. It makes it easier to help you!
Aug 5, 2022, 8:34 PM
user M
💚
Aug 5, 2022, 8:34 PM
Impeccable timing
user F
!
Aug 5, 2022, 8:34 PM
oh yeah sure sorry
Aug 5, 2022, 8:39 PM
this is vue also
would rly appreciate the help doing this for a record label and want it to work perfectly :)
[9:30 PM] its fetching perfectly in vision though

basically I want it to show up on the site in descending order from release num, so DY-002, DY-001 etc
Aug 5, 2022, 8:39 PM
Can you share the link to the Vision query that's working properly? It should be right above your results pane in the plugin.
Aug 5, 2022, 8:49 PM
so it orders it properly by order(releaseNum desc)
Aug 5, 2022, 8:54 PM
The query in production on your website isn’t implementing an
order()
.
Aug 5, 2022, 8:58 PM
what do you mean sorry? i set this as the query *[_type == "post"] | order(releaseNum desc)
Aug 5, 2022, 9:05 PM
What I meant was that if the screenshot is from your production website (which the list order does appear to match), then your query is this:
*[_type == "post"]{ _id, releaseNum, artistName, releaseName, slug, releaseDate, releaseType, anr, }[0...50]
. You can open the Network tab in your dev tools and filter by
production
, and that’s the GET request.
Aug 5, 2022, 9:09 PM
If you’re also seeing that same order in your local or staging environment, where
order()
is implemented in the query, then maybe some screenshots of that would help.
Aug 5, 2022, 9:10 PM
oh im so stupid ahaha. So do I have to order it in the post.js in schemas and then pass it through to the vue file some how?
Aug 5, 2022, 9:26 PM
Not to worry!
No, you don’t need to worry about it in your schema. You’ll want to add
| order(releaseNum desc)
to your query that you’re doing in Vue using the Sanity Client.
Aug 5, 2022, 9:28 PM
thank you! that worked perfectly :D
Aug 5, 2022, 9:54 PM
Glad to hear it, Oliver! Have a good weekend!
Aug 5, 2022, 10:08 PM

Sanity– build remarkable experiences at scale

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

Was this answer helpful?