Skip to content

Commit

Permalink
Workaround undefined errors property on IResult
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-chambers committed Nov 30, 2023
1 parent ac2b909 commit 75d3ba7
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions functions/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { sendSimpleMail, IResult } from 'https://deno.land/x/[email protected]/mod.ts';
import { sendSimpleMail } from 'https://deno.land/x/[email protected]/mod.ts';

type Result = {
success: boolean,
errors: string[]
}

/**
* Uses the SendGrid API to send an email.
Expand All @@ -10,7 +15,7 @@ import { sendSimpleMail, IResult } from 'https://deno.land/x/[email protected]/mod.
* @param html The HTML content of the email
* @returns Success or errors
*/
export async function send(subject: string, to: string, from: string, plain: string, html: string ): Promise<IResult> {
export async function send(subject: string, to: string, from: string, plain: string, html: string ): Promise<Result> {
const API_KEY = Deno.env.get("SENDGRID_API_KEY");

if(! API_KEY) {
Expand All @@ -32,5 +37,8 @@ export async function send(subject: string, to: string, from: string, plain: str
},
);

return response;
return {
success: response.success,
errors: response.errors ?? []
};
}

0 comments on commit 75d3ba7

Please sign in to comment.