@@ -6,7 +6,7 @@ import 'rxjs/add/operator/map';
6
6
7
7
@Injectable ( )
8
8
export class NodeService {
9
-
9
+ baseUrl : string = "http://localhost:3000/" ;
10
10
constructor ( public http : Http ) { }
11
11
12
12
login ( email , password ) {
@@ -15,62 +15,66 @@ export class NodeService {
15
15
let options = new RequestOptions ( { headers : headers , withCredentials : true } ) ;
16
16
let body = JSON . stringify ( data ) ;
17
17
console . log ( body ) ;
18
- return this . http . post ( 'http://localhost:3000/ login', body , options ) ;
18
+ return this . http . post ( this . baseUrl + ' login', body , options ) ;
19
19
}
20
20
signup ( name , email , password , mobile ) {
21
21
var data = { "name" : name , "email" : email , "password" : password , "mobile" : mobile } ;
22
22
let headers = new Headers ( { 'Content-Type' : 'application/json' } ) ;
23
23
let options = new RequestOptions ( { headers : headers } ) ;
24
24
let body = JSON . stringify ( data ) ;
25
25
console . log ( body ) ;
26
- return this . http . post ( 'http://localhost:3000/ signup', body , options ) ;
26
+ return this . http . post ( this . baseUrl + ' signup', body , options ) ;
27
27
}
28
28
home ( ) {
29
29
let options = new RequestOptions ( { withCredentials : true } ) ;
30
- return this . http . get ( "http://localhost:3000/ home", options )
30
+ return this . http . get ( this . baseUrl + " home", options )
31
31
}
32
32
updateCourse ( course_id , course_name , section , content ) {
33
33
var data = { "courseId" : course_id , "courseName" : course_name , "topicName" : section , "courseData" : content } ;
34
34
let headers = new Headers ( { 'Content-Type' : 'application/json' } ) ;
35
35
let options = new RequestOptions ( { headers : headers , withCredentials : true } ) ;
36
36
let body = JSON . stringify ( data ) ;
37
37
console . log ( body ) ;
38
- return this . http . post ( 'http://localhost:3000/ addCourseData', body , options ) ;
38
+ return this . http . post ( this . baseUrl + ' addCourseData', body , options ) ;
39
39
}
40
40
logout ( ) {
41
41
let options = new RequestOptions ( { withCredentials : true } ) ;
42
- return this . http . get ( "http://localhost:3000/ logout", options )
42
+ return this . http . get ( this . baseUrl + " logout", options )
43
43
}
44
44
deleteCourse ( course_name ) {
45
45
var data = { "coursename" : course_name } ;
46
46
let headers = new Headers ( { 'Content-Type' : 'application/json' } ) ;
47
47
let options = new RequestOptions ( { headers : headers , withCredentials : true } ) ;
48
48
let body = JSON . stringify ( data ) ;
49
49
console . log ( body ) ;
50
- return this . http . post ( 'http://localhost:3000/ deleteCourse', body , options ) ;
50
+ return this . http . post ( this . baseUrl + ' deleteCourse', body , options ) ;
51
51
}
52
52
getSections ( course_name ) {
53
53
var data = { "coursename" : course_name } ;
54
54
let headers = new Headers ( { 'Content-Type' : 'application/json' } ) ;
55
55
let options = new RequestOptions ( { headers : headers , withCredentials : true } ) ;
56
56
let body = JSON . stringify ( data ) ;
57
57
console . log ( body ) ;
58
- return this . http . post ( 'http://localhost:3000/ course/'+ course_name , body , options ) ;
58
+ return this . http . post ( this . baseUrl + ' course/'+ course_name , body , options ) ;
59
59
}
60
60
getSectionData ( course_name , section ) {
61
61
var data = { "courseName" : course_name , "section" :section } ;
62
62
let headers = new Headers ( { 'Content-Type' : 'application/json' } ) ;
63
63
let options = new RequestOptions ( { headers : headers , withCredentials : true } ) ;
64
64
let body = JSON . stringify ( data ) ;
65
65
console . log ( body ) ;
66
- return this . http . post ( 'http://localhost:3000/ course/'+ course_name + '/' + section , body , options ) ;
66
+ return this . http . post ( this . baseUrl + ' course/'+ course_name + '/' + section , body , options ) ;
67
67
}
68
68
updateSection ( course_name , topicName , content ) {
69
69
var data = { "courseName" : course_name , "topicName" : topicName , "courseData" : content } ;
70
70
let headers = new Headers ( { 'Content-Type' : 'application/json' } ) ;
71
71
let options = new RequestOptions ( { headers : headers , withCredentials : true } ) ;
72
72
let body = JSON . stringify ( data ) ;
73
73
console . log ( body ) ;
74
- return this . http . post ( 'http://localhost:3000/update-section' , body , options ) ;
74
+ return this . http . post ( this . baseUrl + 'update-section' , body , options ) ;
75
+ }
76
+ session ( ) {
77
+ let options = new RequestOptions ( { withCredentials : true } ) ;
78
+ return this . http . get ( this . baseUrl , options )
75
79
}
76
80
}
0 commit comments