Skip to content

Commit

Permalink
Fixed Firefox CORS issue
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillermoFloresV committed Oct 9, 2022
1 parent a29884e commit 40e7ab1
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions pages/join/[...joinCode].js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,26 @@ export default function JoinWithCode({ userSession }) {
const router = useRouter();
const { joinCode } = router.query;

async function classroomRequest() {
const classroomRequest = async event => {
event.preventDefault();
formData.join = joinCode;
await fetch(`/api/student_email_join`, {
method: 'PUT',
body: JSON.stringify(formData)
});
}
try {
const res = await fetch(`/api/student_email_join`, {
method: 'PUT',
body: JSON.stringify(formData)
});
if (res.status === 409) {
alert('You have already joined this classroom.');
router.push('/');
} else {
alert('Error: ' + res.statusText);
}
} catch (error) {
alert('Sorry, there was an error on our end. Please try again later.');
console.log(error);
router.push('/');
}
};

return (
<>
Expand Down

0 comments on commit 40e7ab1

Please sign in to comment.