// API: Story import { apiVersion, dataset, projectId, useCdn } from 'lib/sanity.api' import { createClient } from 'next-sanity' const client = projectId ? createClient({ projectId: process.env.NEXT_PUBLIC_SANITY_PROJECT_ID, dataset: process.env.NEXT_PUBLIC_SANITY_DATASET, apiVersion: process.env.NEXT_PUBLIC_SANITY_API_VERSION, useCdn: true, token: process.env.SANITY_API_READ_TOKEN, }) : null export const getWedding = async () => { const query = `*[_type == "WeddingSection"][]{ title, subtitle, "coverImageUrl": coverImage.asset->url, pixiesetURL, descriptionTitle, content[]{ children[]{ text, marks[], _type } }, Wedding[]->{ "slug": slug.current, "cover": coverImage.asset->url, }, "package" : Weddingpackage[]->{ title ,content[]{ children[]{ text, marks[], _type } } ,"fileWedding": fileWedding.asset->url }, }` //HomeIntro section try { const data = await client.fetch(query) return data } catch (error) { console.error('Error fetching Sanity data:', error) return null; } } // eslint-disable-next-line import/no-anonymous-default-export export default async (req, res) => { const query = `*[_type == "WeddingSection"][]{ title, subtitle, "coverImageUrl": coverImage.asset->url, pixiesetURL, descriptionTitle, content[]{ children[]{ text, marks[], _type } }, Wedding[]->{ "slug": slug.current, "cover": coverImage.asset->url, }, "package" : Weddingpackage[]->{ title ,content[]{ children[]{ text, marks[], _type } } ,"fileWedding": fileWedding.asset->url }, }` //HomeIntro section try { const data = await client.fetch(query) res.status(200).json(data) } catch (error) { console.error('Error fetching Sanity data:', error) res.status(500).json({ error: 'Error fetching Sanity data' }) } }