Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: send perspective as query param when using GET method #1008

Merged
merged 7 commits into from
Jul 15, 2024

Conversation

jesperbjerke
Copy link
Contributor

This is the same issue as here: #930 but with GET queries. This appends perspective there as well.

@jesperbjerke jesperbjerke requested a review from danielroe as a code owner May 30, 2024 13:44
Copy link

netlify bot commented May 30, 2024

Deploy Preview for nuxt-sanity-module canceled.

Name Link
🔨 Latest commit ab51f84
🔍 Latest deploy log https://app.netlify.com/sites/nuxt-sanity-module/deploys/66953028712f97000860538b

Copy link
Collaborator

@danielroe danielroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just move the query up into fetchOptions?

@jesperbjerke
Copy link
Contributor Author

Should we just move the query up into fetchOptions?

Hah, good point! Completely missed that 😅 Changed now

@jesperbjerke
Copy link
Contributor Author

jesperbjerke commented May 31, 2024

Noticed the RequestInit type doesn't allow for query. And changing it to FetchOptions conflicts with the POST method 🙃
I'll see if I find the correct type to use..

Copy link
Collaborator

@danielroe danielroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually ... Maybe we need to add it to the qs as &perspective= rather than via query for the get request... Seems like it would produce a double query otherwise.

@jesperbjerke
Copy link
Contributor Author

Actually ... Maybe we need to add it to the qs as &perspective= rather than via query for the get request... Seems like it would produce a double query otherwise.

When I tested it just appended perspective to the existing query params and worked as expected. But I can double check again.
What do you mean with "double query" though? 🤔

@jesperbjerke
Copy link
Contributor Author

Just tested again, both with and without defining perspective in my config. Looks to me as it behaves as expected and just appends the perspective to the existing query params. Perspective defaults to "raw" if not defined.

This is the query params it produces for me:
Screenshot 2024-05-31 at 14 56 33

data/query/staging?query=*%5B_type+==+%22article%22+%26%26+language+==+$language+%26%26+slug.current+==+$slug%5D%5B0%5D%7Btitle,+animal_type,+intro,+seo,+body,+image%7D&$language=%22en%22&$slug=%22invaertes-parasiter-hos-kanin-test%22&perspective=previewDrafts

Copy link
Collaborator

@danielroe danielroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you ❤️

@danielroe danielroe merged commit f90722d into nuxt-modules:main Jul 15, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants