Gwk-Cultural-Park/pages/api/whatsnewdata.ts
2024-09-07 08:40:25 +07:00

48 lines
1.0 KiB
TypeScript

// API: What's New (Home)
import { projectId } 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
fetch('{https://cmswp.gwkbali.com/graphql}l', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: `{
monthlyReleases {
edges {
node {
excerpt(format: RENDERED)
id
slug
title
featuredImage {
node {
altText
sourceUrl
}
}
}
}
}
}`,
}),
}).then((res) => res.json())
//.then((res) => console.log('Data:', res.data))
//export default whatsnewData