Skip to content

Commit

Permalink
crete api
Browse files Browse the repository at this point in the history
  • Loading branch information
bertfarol committed May 22, 2023
1 parent 624f38f commit 7bc3a82
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions pages/api/getTodos.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import { createClient, groq } from "next-sanity";
import sanity from "@/sanity/lib/client-config";

const feedQuery = groq`
const feedQuery = `
*[_type == "todo"] {
_id,
...
} | order(_createdAt desc)
`;

export default async function handler(req, res) {
const client = createClient({
projectId: "0wtsa0of",
dataset: "production",
apiVersion: "2023-05-20",
});
const todos = await client.fetch(feedQuery);
res.setHeader("Cache-Control", "no-store");
const todos = await sanity.fetch(feedQuery);
res.status(200).json(todos);
}

1 comment on commit 7bc3a82

@vercel
Copy link

@vercel vercel bot commented on 7bc3a82 May 22, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.