From 1ad1e1ab4326156b46f222f83a04ceaf5d012128 Mon Sep 17 00:00:00 2001 From: Karl Horky Date: Mon, 9 Jun 2025 17:39:54 +0200 Subject: [PATCH] Rename `data` to `response`, add error handling block --- index.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/index.ts b/index.ts index 08069e5..f7c93b1 100644 --- a/index.ts +++ b/index.ts @@ -3,14 +3,19 @@ const resend = new Resend('re_123456789'); (async function() { try { - const data = await resend.emails.send({ + const response = await resend.emails.send({ from: 'Acme ', to: ['delivered@resend.dev'], subject: 'Hello World', html: 'It works!' }); - console.log(data); + if (response.error) { + console.error(response.error) + return; + } + + console.log(response); } catch (error) { console.error(error); }