Use our own API instead of the test one #4
2 changed files with 8 additions and 5 deletions
10
app/page.tsx
10
app/page.tsx
|
@ -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>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue