From 7f22762beeca6f3128be339ebd2dbeb746f9a0a1 Mon Sep 17 00:00:00 2001 From: Kazuya Takei Date: Sun, 24 Nov 2024 22:24:50 +0900 Subject: [PATCH] feat: Add error-message --- src/routes/htmx.tsx | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/routes/htmx.tsx b/src/routes/htmx.tsx index 319edd4..aa87304 100644 --- a/src/routes/htmx.tsx +++ b/src/routes/htmx.tsx @@ -20,17 +20,24 @@ app.post('/content-url', zValidator('json', ContentAddress), async (c) => { 'content-type': 'application/json', }, }); - const data = await resp.json(); + if (resp.ok) { + const data = await resp.json(); + return c.html( + +

Content URL is created!

+

+ Link is{' '} + + here + + . +

+
, + ); + } return c.html( - -

Content URL is created!

-

- Link is{' '} - - here - - . -

+ +

{await resp.text()}

, ); });