Created
October 29, 2025 13:12
-
-
Save rudin/73fae21dad6c4bb2e430ec9a36460885 to your computer and use it in GitHub Desktop.
Events
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { createClient } from "@sanity/client"; | |
| const client = createClient({ | |
| projectId: "bcvqsdfp", | |
| dataset: "production", | |
| apiVersion: "2023-01-01", | |
| useCdn: true, | |
| }); | |
| export const fetchEvents = async () => { | |
| const query = ` | |
| { | |
| "events": *[_type == "event"] { | |
| _id, | |
| title, | |
| startDate, | |
| endDate, | |
| image, | |
| description, | |
| categories, | |
| subCategories, | |
| addressReference->, | |
| address, | |
| postalCode, | |
| city, | |
| phone, | |
| email, | |
| contactPerson, | |
| website, | |
| geoLocation, | |
| }, | |
| "settings": *[_type == "settings"] { | |
| ..., | |
| categories[]->{ | |
| ... | |
| } | |
| } | |
| } | |
| `; | |
| try { | |
| const data = await client.fetch(query, {}, { method: "POST" }); // Force POST request | |
| return data; | |
| } catch (error) { | |
| console.error("Error fetching events:", error); | |
| return null; | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment