Skip to content

Commit adbdc3f

Browse files
author
Holly Williams
committed
added async/await to react
1 parent 3103cca commit adbdc3f

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

frontend/src/App.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,20 @@ function handleErrors(response) {
2424
return response;
2525
}
2626

27-
const sendEmails = () => {
27+
const sendEmails = async () => {
2828
const data = {templateName: 'emailTemplate', percentOfEmails: '22'}
2929
alert('Sending emails!');
3030

3131
// curl -H "Content-Type: application/json" http://localhost:8080/surveys/send -d "{"""templateName""":"""emailTemplate""","""percentOfEmails""":"""22"""}" -X POST
3232

33-
const response = fetch('http://localhost:8080/surveys/send', {
33+
const response = await fetch('http://localhost:8080/surveys/send', {
3434
method: 'POST',
3535
cache: 'no-cache',
3636
headers: {
3737
'Accept': 'application/json',
38-
// 'Content-Type': 'application/json'
38+
'Content-Type': 'application/json'
3939
},
40-
body: JSON.stringify({ templateName: 'emailTemplate' , percentOfEmails: '22' }),
41-
data: null
40+
body: JSON.stringify({ templateName: 'emailTemplate' , percentOfEmails: '22' })
4241
})
4342
.then(handleErrors)
4443
.then(response => {console.log(response)})

0 commit comments

Comments
 (0)