From 6a2cc7014feb349557ab63b9dd7fdac3cfc967d6 Mon Sep 17 00:00:00 2001 From: Pierre Martin Date: Sun, 17 Mar 2024 00:16:22 +0100 Subject: [PATCH] ky --- packages/hello-world/hello.tsx | 21 +++++++++++++++++++++ packages/hello-world/package.json | 1 + pnpm-lock.yaml | 8 ++++++++ 3 files changed, 30 insertions(+) diff --git a/packages/hello-world/hello.tsx b/packages/hello-world/hello.tsx index fe18944..cb48d26 100644 --- a/packages/hello-world/hello.tsx +++ b/packages/hello-world/hello.tsx @@ -1,6 +1,7 @@ import React from "react"; import op from "object-path"; import config from "~/config"; +import ky from "ky"; // const config = { // title: "Hello World", // description: "Hello World description", @@ -17,11 +18,31 @@ const data = { }; const HelloWorld: React.FC = () => { + const [state, setState] = React.useState([]); + React.useEffect(() => { + ky.get("https://jsonplaceholder.typicode.com/todos/") + .json() + .then((data) => { + setState(data); + }); + }, []); + return (
Hello World !

{data.description}

Name: {op.get(data, "og.title")}

+ +
+

TODO Data

+
    + {state.map((item, index) => ( +
  • + {item.completed ? "✅" : "🤷"} - {item.title} (#{item.id}) +
  • + ))} +
+
); }; diff --git a/packages/hello-world/package.json b/packages/hello-world/package.json index 3fb0165..dc64439 100644 --- a/packages/hello-world/package.json +++ b/packages/hello-world/package.json @@ -20,6 +20,7 @@ "react": "^18.2.0" }, "dependencies": { + "ky": "^1.2.2", "object-path": "^0.11.8" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a47a336..9774616 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ importers: packages/hello-world: dependencies: + ky: + specifier: ^1.2.2 + version: 1.2.2 object-path: specifier: ^0.11.8 version: 0.11.8 @@ -4000,6 +4003,11 @@ packages: engines: {node: '>=6'} dev: true + /ky@1.2.2: + resolution: {integrity: sha512-gYA2QOI3uIaImJPJjaBbLCdvKHzwxsuB03s7PjrXmoO6tcn6k53rwYoSRgqrmVsEV6wFFegOXDVjABxFZ0aRSg==} + engines: {node: '>=18'} + dev: false + /language-subtag-registry@0.3.22: resolution: {integrity: sha512-tN0MCzyWnoz/4nHS6uxdlFWoUZT7ABptwKPQ52Ea7URk6vll88bWBVhodtnlfEuCcKWNGoc+uGbw1cwa9IKh/w==} dev: true