Skip to content

Commit 394acb3

Browse files
committed
Added login form handler
1 parent 541ded5 commit 394acb3

File tree

1 file changed

+35
-17
lines changed

1 file changed

+35
-17
lines changed

src/views/LoginSignup.vue

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,29 +99,16 @@ export default {
9999
this.loginForm.timeStamp = new Date()
100100
// store.dispatch('userSavesNote', { note: this.form })
101101
console.log(JSON.stringify(this.loginForm))
102+
this.postLogin({
103+
userName: this.loginForm.userName,
104+
password: this.loginForm.password
105+
})
102106
this.loginForm = {
103107
userName: '',
104108
password: '',
105109
timeStamp: null
106110
}
107111
},
108-
postSignUp (data) {
109-
console.log(data)
110-
const URI = process.env.VUE_APP_URI || 'http://localhost:4000'
111-
axios
112-
.post(`${URI}/signup`, data)
113-
.then(response => {
114-
console.log(response.data.msg)
115-
// this.info = response.data.msg
116-
})
117-
.catch(error => {
118-
console.log(error)
119-
// this.errored = true
120-
})
121-
.finally(() => {
122-
// this.loading = false
123-
})
124-
},
125112
onSignUpSubmit (evt) {
126113
evt.preventDefault()
127114
this.signUpForm.timeStamp = new Date()
@@ -139,10 +126,41 @@ export default {
139126
password: '',
140127
timeStamp: null
141128
}
129+
},
130+
postLogin (data) {
131+
axios
132+
.post(`${this.URI}/login`, data)
133+
.then(response => {
134+
console.log(response.data.msg)
135+
// this.info = response.data.msg
136+
})
137+
.catch(error => {
138+
console.log(error)
139+
// this.errored = true
140+
})
141+
.finally(() => {
142+
// this.loading = false
143+
})
144+
},
145+
postSignUp (data) {
146+
axios
147+
.post(`${this.URI}/signup`, data)
148+
.then(response => {
149+
console.log(response.data.msg)
150+
// this.info = response.data.msg
151+
})
152+
.catch(error => {
153+
console.log(error)
154+
// this.errored = true
155+
})
156+
.finally(() => {
157+
// this.loading = false
158+
})
142159
}
143160
},
144161
data () {
145162
return {
163+
URI: process.env.VUE_APP_URI || 'http://localhost:4000',
146164
loginForm: {
147165
userName: '',
148166
password: '',

0 commit comments

Comments
 (0)