1
1
const express = require ( "express" ) ;
2
2
const router = express . Router ( ) ;
3
- const behaviour = require ( "./util/behaviour" ) ;
4
3
const error = require ( "./error" ) ;
5
4
6
5
const parse = require ( "body-parser" ) ;
7
6
const index = require ( "./../model/index" ) ;
8
- const questionsList = index . questions ;
9
7
const postData = index . formPost ;
10
8
const getData = index . getUsers ;
11
9
const home = require ( "./home" ) ;
@@ -14,40 +12,7 @@ router.get("/", home);
14
12
15
13
console . log ( "I am here" ) ;
16
14
17
- router . post ( "/create-user" , ( req , res ) => {
18
- // console.log(req.body);
19
- const questionsArray = [
20
- req . body . q1 ,
21
- req . body . q2 ,
22
- req . body . q3 ,
23
- req . body . q4 ,
24
- req . body . q5 ,
25
- req . body . q6 ,
26
- req . body . q7
27
- ] ;
28
-
29
- let goodOrBad ;
30
- let totalPoint = behaviour ( questionsArray ) ;
31
- if ( totalPoint >= 4 ) {
32
- goodOrBad = true ;
33
- } else {
34
- goodOrBad = false ;
35
- }
36
-
37
- postData ( {
38
- name : req . body . username ,
39
- behaviour : goodOrBad ,
40
- category : req . body . category
41
- } )
42
- . then ( responseDb => {
43
- res . redirect ( "/presents" ) ;
44
- } )
45
- . catch ( error => {
46
- throw error ;
47
- } ) ;
48
-
49
- // res.redirect('/presents');
50
- } ) ;
15
+ router . post ( "/create-user" ,
51
16
router . get ( "/presents" , ( req , res ) => {
52
17
console . log ( "we're getting data" ) ;
53
18
0 commit comments