diff --git a/typewriter/src/App.tsx b/typewriter/src/App.tsx
index fe3491a..1ec4cdb 100644
--- a/typewriter/src/App.tsx
+++ b/typewriter/src/App.tsx
@@ -1,9 +1,23 @@
-import React from 'react';
+import { useEffect, useState } from "react";
+import { fetchBodyText } from "./api/fetchBodyText";
function App() {
+ const [bodyText, setBodyText] = useState("");
+ const [loading, setLoading] = useState(true);
+
+ useEffect(() => {
+ async function load() {
+ setLoading(true);
+ const text = await fetchBodyText();
+ setBodyText(text);
+ setLoading(false);
+ }
+ load();
+ }, []);
+
return (
- Hello World!
+ {loading ?
Loading...
:
{bodyText}
}
);
}
diff --git a/typewriter/src/api/fetchBodyText.ts b/typewriter/src/api/fetchBodyText.ts
new file mode 100644
index 0000000..8e8ab15
--- /dev/null
+++ b/typewriter/src/api/fetchBodyText.ts
@@ -0,0 +1,19 @@
+const url = "https://wgg522pwivhvi5gqsn675gth3q0otdja.lambda-url.us-east-1.on.aws/6f7665";
+
+export async function fetchBodyText(): Promise {
+ try {
+ const response = await fetch(url);
+ const html = await response.text();
+
+ const parser = new DOMParser();
+ const doc = parser.parseFromString(html, "text/html");
+
+ const body = doc.body;
+ const text = body?.textContent?.trim();
+
+ return text ?? "";
+ } catch (error) {
+ console.error("Error fetching or parsing HTML:", error);
+ return "";
+ }
+}
\ No newline at end of file