Use our own API instead of the test one #4

Merged
graphite merged 1 commit from graphite/own-api into main 2024-06-01 11:22:28 +03:00 AGit
2 changed files with 8 additions and 5 deletions
Showing only changes of commit e2955ef5bb - Show all commits

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"