-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmailer.js
36 lines (30 loc) · 934 Bytes
/
mailer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* @flow */
'use strict';
const React = require('react');
var {
Alert
} = React;
const Tcomb = require('tcomb-form-native');
var url = 'https://microsoft-apiapp04962ba69aa74a76af6ae027d5493b6d.azurewebsites.net/api/SendGrid?parentdestEmailAddress={0}&childName={1}&childUniqueId={2}';
class Mailer extends React.Component {
async sendMail(child : Tcomb.struct, childUniqueId : string) {
var childFullName = child.firstName + ' ' + child.lastName;
url = url.replace('{0}', child.emailAddress);
url = url.replace('{1}', childFullName);
url = url.replace('{2}', childUniqueId);
url = encodeURI(url);
try {
fetch(url
, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
}
});
} catch (error) {
throw error;
}
}
}
module.exports = Mailer;