Skip to content

Commit

Permalink
Connect StudentSignup React form to database
Browse files Browse the repository at this point in the history
- Using axios with async/await
- Tested with Postman and it is working, yay!
- Relates #44
  • Loading branch information
misterrodger committed Jun 13, 2019
1 parent 29581f8 commit 898da24
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/components/StudentSignupForm/StudentSignupForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,19 @@ function StudentSignupForm() {

const handleSubmit = (event) => {
event.preventDefault();
console.log(data)
// const addStudent = async () => {
// console.log(`Fake submitting: ${data}`);
// try {
// return await
// axios.post('/api/student/create', this.data)
// } catch(error) {
// console.error(error)
// }
// }
// addStudent();
// props.history.push('/dashboard');
setData({firstName:"", lastName: "", email: "", //clear form on submit
phoneNumber: null, password: "", university: "", yearOfStudy: 0,

const addStudent = async () => {
console.log(`Fake submitting: ${data}`);
try {
return await
axios.post('/api/student/sign-up', data)
} catch(error) {
console.error(error)
}
}
addStudent();
setData({firstName:"", lastName: "", email: "", //clear form on submit
phoneNumber: "", password: "", university: "", yearOfStudy: "",
courseStudied: "", aboutYou: "", LinkedinURL: ""});
}

Expand Down

0 comments on commit 898da24

Please sign in to comment.