Compare commits

...

1 commit

Author SHA1 Message Date
0d3ad083c6 Use our own API instead of the test one (#4)
Co-authored-by: Alex Stan <alex.stan.2010@proton.me>
Co-committed-by: Alex Stan <alex.stan.2010@proton.me>
2024-06-01 11:22:28 +03:00
2 changed files with 8 additions and 5 deletions

View file

@ -1,7 +1,7 @@
import Image from "next/image"; import Image from "next/image";
async function getData() { async function getData( url: string ) {
const res = await fetch('https://my-json-server.typicode.com/typicode/demo/posts'); const res = await fetch( url );
// The return value is *not* serialized // The return value is *not* serialized
// You can return Date, Map, Set, etc. // You can return Date, Map, Set, etc.
@ -14,10 +14,12 @@ async function getData() {
} }
export default async function Home() { export default async function Home() {
const data = await getData(); const data = await getData( "http://localhost:4000/questions" );
return ( return (
<main> <main>
<p className = "text-lg font-sans hover:text-xl">{ data[ 1 ].title } </p> { data.map( (item: any) => (
<p className = "text-lg font-sans hover:text-xl">{ item.question } </p>
) ) }
</main> </main>
); );
} }

View file

@ -3,7 +3,7 @@
"lib": ["dom", "dom.iterable", "esnext"], "lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true, "allowJs": true,
"skipLibCheck": true, "skipLibCheck": true,
"strict": true, "strict": false,
"noEmit": true, "noEmit": true,
"esModuleInterop": true, "esModuleInterop": true,
"module": "esnext", "module": "esnext",
@ -12,6 +12,7 @@
"isolatedModules": true, "isolatedModules": true,
"jsx": "preserve", "jsx": "preserve",
"incremental": true, "incremental": true,
"noImplicitAny": false,
"plugins": [ "plugins": [
{ {
"name": "next" "name": "next"