Skip to content

Instantly share code, notes, and snippets.

@rudin
Created October 29, 2025 13:12
Show Gist options
  • Select an option

  • Save rudin/73fae21dad6c4bb2e430ec9a36460885 to your computer and use it in GitHub Desktop.

Select an option

Save rudin/73fae21dad6c4bb2e430ec9a36460885 to your computer and use it in GitHub Desktop.
Events
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