Skip to content

Commit d7de24c

Browse files
authored
fix(contact-form): two small mistakes (#342)
1. Front end: if a form submission fails due to a 500 error, the submit button previously stayed disabled. This adds a finally block to re-enable the button after everything else has happened. 2. Back end: two Twilio.Response objects were initialized when only one is needed.
1 parent 76130d5 commit d7de24c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

contact-form/assets/index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,14 @@ <h2>Contact form</h2>
157157
console.log(data);
158158
setStatus(data.error, "error");
159159
}
160-
sendButton.removeAttribute("disabled");
161160
} catch (error) {
162161
setStatus(
163162
"There was an error and the message could not be sent. Sorry.",
164163
"error"
165164
);
166165
console.log(error);
166+
} finally {
167+
sendButton.removeAttribute("disabled");
167168
}
168169
});
169170
</script>

contact-form/functions/send-email.js

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ exports.handler = async function (context, event, callback) {
3838

3939
try {
4040
await sg.send(msg);
41-
const response = new Twilio.Response();
4241
response.setStatusCode(200);
4342
response.setBody({ success: true });
4443
return callback(null, response);

0 commit comments

Comments
 (0)