From 3acac648ad6f7c220a48ff9f92f42e814c2097ab Mon Sep 17 00:00:00 2001 From: real-zephex Date: Tue, 26 Mar 2024 13:21:55 +0530 Subject: restructured files --- src/app/anime/search/components/fetchInfo.js | 14 ++++++++ src/app/anime/search/components/fetchedInfo.js | 44 ++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 src/app/anime/search/components/fetchInfo.js create mode 100644 src/app/anime/search/components/fetchedInfo.js (limited to 'src/app/anime/search/components') diff --git a/src/app/anime/search/components/fetchInfo.js b/src/app/anime/search/components/fetchInfo.js new file mode 100644 index 0000000..07b203d --- /dev/null +++ b/src/app/anime/search/components/fetchInfo.js @@ -0,0 +1,14 @@ +"use server"; + +export default async function Results(id) { + return await testFunction(id); +} + +async function testFunction(title) { + const res = await fetch( + "https://consumet-api-di2e.onrender.com/anime/gogoanime/" + title, + { cache: "force-cache" } + ); + const data = await res.json(); + return data; +} diff --git a/src/app/anime/search/components/fetchedInfo.js b/src/app/anime/search/components/fetchedInfo.js new file mode 100644 index 0000000..17c9673 --- /dev/null +++ b/src/app/anime/search/components/fetchedInfo.js @@ -0,0 +1,44 @@ +import "../search.css"; +import Link from "next/link"; +import Image from "next/image"; + +export default async function fetchedInfo(data) { + return ( +
+ {data ? ( + data.results && data.results.length > 0 ? ( + data.results.map((item, index) => ( + +
+

{item.title}

+ Drama Poster +
+ + )) + ) : ( +
+

+ No results found +

+
+ ) + ) : null} +
+ ); +} -- cgit v1.2.3