1export default async function(req: Request): Promise<Response> {
2 const response = await fetch("https://api.thecatapi.com/v1/images/search");
3 const [catData] = await response.json();
4 return Response.json({ url: catData.url });
1export default async function(req: Request): Promise<Response> {
2 const response = await fetch("https://api.thecatapi.com/v1/images/search");
3 const [catData] = await response.json();
4 return Response.json({ url: catData.url });
1export default async function(req: Request): Promise<Response> {
2 const response = await fetch("https://api.thecatapi.com/v1/images/search");
3 const [catData] = await response.json();
4 return Response.json({ url: catData.url });
1export default async function(req: Request): Promise<Response> {
2 const response = await fetch("https://api.thecatapi.com/v1/images/search");
3 const [catData] = await response.json();
4 return Response.json({ url: catData.url });
1export default async function(req: Request): Promise<Response> {
2 const response = await fetch("https://api.thecatapi.com/v1/images/search");
3 const [catData] = await response.json();
4 return Response.json({ url: catData.url });
1export default async function(req: Request): Promise<Response> {
2 const url = new URL(req.url);
3 return fetch(new URL(url.pathname + url.search, "https://cat--ad694aca-05d7-11f0-b1bc-569c3dd06744.web.val.run/"), {
4 method: req.method,
5 headers: req.headers,
14
15// React.useEffect(() => {
16// fetchGreetings();
17// }, []);
18
19// async function fetchGreetings() {
20// try {
21// const response = await client["/greetings"].get();
26// setGreetings(data);
27// } catch (e) {
28// console.error("Failed to fetch greetings:", e);
29// setError("Failed to fetch greetings. Please try again later.");
30// }
31// }
6
7export type RequestHandler = (request: Request) => Promise<Response>;
8export type DataFetcher<T> = (request: Request) => Promise<T>;
9
10// export type DataRequest<T> = Request & { data: T };
132 return api(req);
133};
134const deprecatedGetInitiaProps = (getProps: DataFetcher<any>): Middleware => async (req, res, next) => {
135 if (!getProps) return next();
136 const data = await getProps(req);
144 /** DEPRECATED: Optional API request handler for all non-GET methods */
145 api?: RequestHandler;
146 /** DEPRECATED: data fetcher to set initial props based on request */
147 getInitialProps?: DataFetcher<any>;
148}
1export default async function(req: Request): Promise<Response> {
2 const url = new URL(req.url);
3 return fetch(
4 new URL(url.pathname + url.search, "https://charmaine--5ad9e364-05c3-11f0-a042-569c3dd06744.web.val.run/"),
5 {
1export default async function(req: Request): Promise<Response> {
2 const url = new URL(req.url);
3 return fetch(new URL(url.pathname + url.search, "https://charmaine--5ad9e364-05c3-11f0-a042-569c3dd06744.web.val.run/"), {
4 method: req.method,
5 headers: req.headers,