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>
This commit is contained in:
Alex Stan 2024-06-01 11:22:28 +03:00 committed by Alex Stan
parent 819760817e
commit 0d3ad083c6
2 changed files with 8 additions and 5 deletions

View file

@ -1,7 +1,7 @@
import Image from "next/image";
async function getData() {
const res = await fetch('https://my-json-server.typicode.com/typicode/demo/posts');
async function getData( url: string ) {
const res = await fetch( url );
// The return value is *not* serialized
// You can return Date, Map, Set, etc.
@ -14,10 +14,12 @@ async function getData() {
}
export default async function Home() {
const data = await getData();
const data = await getData( "http://localhost:4000/questions" );
return (
<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>
);
}

View file

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