File tree 3 files changed +15
-24
lines changed
3 files changed +15
-24
lines changed Original file line number Diff line number Diff line change 32
32
< script src ="node_modules/angular-localforage/dist/angular-localForage.js "> </ script >
33
33
<!-- main app file -->
34
34
< script src ="js/app.js "> </ script >
35
+ <!-- constance -->
36
+ < script src ="js/httpConfig.js "> </ script >
35
37
<!-- controllers -->
36
38
< script src ="js/controllers/mainCtrl.js "> </ script >
37
39
< script src ="js/controllers/externalCtrl.js "> </ script >
38
40
<!-- services (the interesting part indeed) -->
39
41
< script src ="js/services/colorCheckerService.js "> </ script >
40
42
< script src ="js/services/colorChangerService.js "> </ script >
41
43
< script src ="js/services/stateService.js "> </ script >
44
+ < script src ="js/services/registerService.js "> </ script >
42
45
<!-- directives -->
43
46
< script src ="js/directives/topbar.js "> </ script >
44
47
< script src ="js/directives/modalOverlay.js "> </ script >
Original file line number Diff line number Diff line change 16
16
$scope . password = '' ;
17
17
$scope . passwordConf = '' ;
18
18
$scope . hideModal = ( ) => stateService . set ( 'modalRegister' , false ) ;
19
- $scope . register = ( ) => {
19
+ $scope . register = async ( ) => {
20
20
if ( $scope . password !== $scope . passwordConf ) {
21
21
alert ( 'Passwords are not equal!' )
22
22
} else {
23
23
const params = {
24
24
email : $scope . email ,
25
25
password : $scope . password
26
26
} ;
27
- registerService . register ( params ) ;
27
+ const response = await registerService . register ( params ) ;
28
+ console . log ( response ) ;
28
29
}
29
30
}
30
31
}
Original file line number Diff line number Diff line change 2
2
'use strict' ;
3
3
4
4
angular
5
- . module ( 'accTrader ' )
5
+ . module ( 'app ' )
6
6
. service ( 'registerService' , Service ) ;
7
7
8
- Service . $inject = [ '$http' ] ;
9
-
10
- function Service ( $http ) {
11
- this . registerUser = function ( registerInfo ) {
8
+ Service . $inject = [ '$http' , 'httpConfig' ] ;
12
9
10
+ function Service ( $http , httpConfig ) {
11
+ this . register = function ( params ) {
13
12
return $http ( {
14
- url : 'https://acctrader.herokuapp.com/v1/sign_up' ,
15
- headers : {
16
- 'Content-Type' : 'application/vnd.api+json'
17
- } ,
13
+ url : httpConfig . baseUrl + '/user/register' ,
14
+ headers : { 'Content-Type' : 'application/json' } ,
18
15
method : 'POST' ,
19
- data : {
20
- user : {
21
- email : registerInfo . email ,
22
- nick : registerInfo . nick ,
23
- password : registerInfo . password ,
24
- password_confirmation : registerInfo . password_confirmation
25
- }
26
- }
16
+ data : params
27
17
} )
28
- . then ( function ( response ) {
29
- return response . data ;
30
- } , function ( err ) {
31
- return err ;
32
- } ) ;
18
+ . then ( response => { return response . data } )
19
+ . catch ( err => { console . log ( err ) } )
33
20
} ;
34
21
}
35
22
} ) ( ) ;
You can’t perform that action at this time.
0 commit comments