Merge branch 'develop' of git.lumeweb.com:LumeWeb/web3.news into develop
This commit is contained in:
commit
487c5de10a
|
@ -1,11 +1,8 @@
|
||||||
import type { NextApiRequest, NextApiResponse } from "next";
|
|
||||||
import { fetchFeedData } from "@/lib/feed.ts";
|
import { fetchFeedData } from "@/lib/feed.ts";
|
||||||
|
import { type NextRequest, NextResponse } from "next/server";
|
||||||
|
|
||||||
export default async function handler(
|
export async function GET(req: NextRequest) {
|
||||||
req: NextApiRequest,
|
const { filter, page = "0" } = req.nextUrl.searchParams as any as {
|
||||||
res: NextApiResponse,
|
|
||||||
) {
|
|
||||||
const { filter, page = "0" } = req.query as any as {
|
|
||||||
filter: "latest" | "day" | "week" | "month";
|
filter: "latest" | "day" | "week" | "month";
|
||||||
page: string;
|
page: string;
|
||||||
};
|
};
|
||||||
|
@ -29,10 +26,8 @@ export default async function handler(
|
||||||
// Fetch data using the fetchFeedData function
|
// Fetch data using the fetchFeedData function
|
||||||
const dataResponse = await fetchFeedData(queryParams);
|
const dataResponse = await fetchFeedData(queryParams);
|
||||||
|
|
||||||
// Send the response back
|
return NextResponse.json(dataResponse);
|
||||||
res.status(200).json(dataResponse);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Handle any errors
|
return NextResponse.json({ error: "Internal Server Error" });
|
||||||
res.status(500).json({ error: "Internal Server Error" });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,7 +5,7 @@ import * as ScrollArea from "@radix-ui/react-scroll-area";
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { Article } from "../lib/prisma.ts";
|
import { Article } from "../lib/prisma.ts";
|
||||||
import useSWR from "swr";
|
import useSWR from "swr";
|
||||||
import { ApiResponse, fetchFeedData } from "../lib/feed.ts";
|
import { ApiResponse } from "../lib/feed.ts";
|
||||||
|
|
||||||
const fetcher = (url: string) => fetch(url).then((r) => r.json());
|
const fetcher = (url: string) => fetch(url).then((r) => r.json());
|
||||||
|
|
||||||
|
@ -39,7 +39,9 @@ const Feed = ({
|
||||||
revalidateOnReconnect: false,
|
revalidateOnReconnect: false,
|
||||||
shouldRetryOnError: false,
|
shouldRetryOnError: false,
|
||||||
fallbackData:
|
fallbackData:
|
||||||
currentPage === 0 ? { data: initialData, current: 0, next: 5 } : undefined, // Use initialData only for the first page
|
currentPage === 0
|
||||||
|
? { data: initialData, current: 0, next: 5 }
|
||||||
|
: undefined, // Use initialData only for the first page
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue