Skip to content

Commit

Permalink
m
Browse files Browse the repository at this point in the history
  • Loading branch information
solita-nhuttu committed Feb 8, 2024
1 parent 0a6b893 commit bd945b6
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/app/testin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,33 @@ import { useState } from "react";

const Testin = () => {
const [data, setData] = useState();
const [num, setNum] = useState(1);

const testFetch = async () => {
try {
const res = await fetch("https://jsonplaceholder.typicode.com/todos/1");
const res = await fetch(
"https://jsonplaceholder.typicode.com/todos/" + num,
);

const json = await res.json();

setNum((prev) => prev + 1);

setData(json);
} catch (error) {
console.log(error);
}
};

testFetch();

return <div>{JSON.stringify(data)}</div>;
return (
<div>
{process.env.NEXT_PUBLIC_HEY ?? "ei ole heytä"}
<button className="border-solid" onClick={() => testFetch()}>
Fetch!
</button>
{JSON.stringify(data)}
</div>
);
};

export default Testin;

0 comments on commit bd945b6

Please sign in to comment.