Skip to content

Commit d9cccc0

Browse files
committed
add example of the EmailJS error handler
1 parent ef3240a commit d9cccc0

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,31 @@ emailjs
107107
);
108108
```
109109

110+
**await/async with EmailJS error handler**
111+
112+
```js
113+
import emailjs, { EmailJSResponseStatus } from '@emailjs/browser';
114+
115+
try {
116+
await emailjs.send(
117+
'YOUR_SERVICE_ID',
118+
'YOUR_TEMPLATE_ID',
119+
{},
120+
{
121+
publicKey: 'YOUR_PUBLIC_KEY',
122+
},
123+
);
124+
console.log('SUCCESS!');
125+
} catch (err) {
126+
if (err instanceof EmailJSResponseStatus) {
127+
console.log('EMAILJS FAILED...', err);
128+
return;
129+
}
130+
131+
console.log('ERROR', err);
132+
}
133+
```
134+
110135
## Configuration
111136

112137
**Options**

0 commit comments

Comments
 (0)