Ensure credentials are included in RSVP request

This commit is contained in:
2017-02-13 13:13:28 +00:00
parent f5cf846259
commit 56a6e2df30

View File

@@ -48,27 +48,29 @@ class RsvpButton extends React.Component {
} }
validateRsvp = () => { validateRsvp = () => {
fetch(`rsvp/${this.rsvpInput.value}`) fetch(`rsvp/${this.rsvpInput.value}`, {
.then(data => { method: 'get',
if (data.status === 200) { credentials: 'include',
location.href = data.url; }).then(data => {
} else { if (data.status === 200) {
this.setState({ location.href = data.url;
inputInvalid: true, } else {
inputInvalidMsg: 'Sorry, that RSVP code is invalid.',
});
setTimeout(() => {
this.setState({
inputInvalid: false,
});
}, 500);
}
}).catch(() => {
this.setState({ this.setState({
inputInvalid: true, inputInvalid: true,
inputInvalidMsg: 'Sorry, there was a problem validating your RSVP code, please try again later.', inputInvalidMsg: 'Sorry, that RSVP code is invalid.',
}); });
setTimeout(() => {
this.setState({
inputInvalid: false,
});
}, 500);
}
}).catch(() => {
this.setState({
inputInvalid: true,
inputInvalidMsg: 'Sorry, there was a problem validating your RSVP code, please try again later.',
}); });
});
} }
render() { render() {