Skip to content

Commit

Permalink
update api
Browse files Browse the repository at this point in the history
  • Loading branch information
bertfarol committed May 22, 2023
1 parent 7bc3a82 commit 5b47d76
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 18 deletions.
2 changes: 1 addition & 1 deletion modules/TodoListTable/components/TaskTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function TaskTable({

return (
<>
{rows}
{tasks.length > 0 && rows}
{tasks.length > 0 && (
<Button
onClick={onClearAll}
Expand Down
13 changes: 0 additions & 13 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,6 @@
*/
const nextConfig = {
reactStrictMode: true,
async headers() {
return [
{
source: "/",
headers: [
{
key: "Cache-Control",
value: "s-maxage=1, stale-while-revalidate=59",
},
],
},
];
},
};

module.exports = nextConfig
4 changes: 3 additions & 1 deletion pages/api/getTodos.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import sanity from "@/sanity/lib/client-config";
const feedQuery = `
*[_type == "todo"] {
_id,
...
_createdAt,
details,
completed,
} | order(_createdAt desc)
`;

Expand Down
8 changes: 5 additions & 3 deletions sanity/lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ const headers = {
};

export async function getAllItems() {
const query = `*[_type == "todo"]`;
const response = await sanity.fetch(query, { cache: "no-store" });
return response;
const response = await fetch(`http://localhost:3000/api/getTodos`, {
cache: 'no-store'
});
const data = await response.json();
return data;
}

export async function getItemById(itemId) {
Expand Down

1 comment on commit 5b47d76

@vercel
Copy link

@vercel vercel bot commented on 5b47d76 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.