@@ -24,31 +24,27 @@ export class HttpClientService {
2424
2525 getEmployees ( )
2626 {
27- let basicString = this . getHeaders ( ) ;
28-
29- let headers = new HttpHeaders (
30- { Authorization :basicString }
31- ) ;
32- console . log ( "test call" ) ;
33- return this . httpClient . get < Employee [ ] > ( 'http://localhost:8080/employees' , { headers} ) ;
27+ let username = 'javainuse'
28+ let password = 'password'
29+
30+ const headers = new HttpHeaders ( { Authorization : 'Basic ' + btoa ( username + ':' + password ) } ) ;
31+
32+ return this . httpClient . get < Employee [ ] > ( 'http://localhost:8080/employees' , { headers} ) ;
3433 }
3534
3635 public deleteEmployee ( employee ) {
37- return this . httpClient . delete < Employee > ( "http://localhost:8080/employees" + "/" + employee . empId ) ;
36+ let username = 'javainuse'
37+ let password = 'password'
38+
39+ const headers = new HttpHeaders ( { Authorization : 'Basic ' + btoa ( username + ':' + password ) } ) ;
40+ return this . httpClient . delete < Employee > ( "http://localhost:8080/employees" + "/" + employee . empId , { headers} ) ;
3841 }
3942
4043 public createEmployee ( employee ) {
41- return this . httpClient . post < Employee > ( "http://localhost:8080/employees" , employee ) ;
44+ let username = 'javainuse'
45+ let password = 'password'
46+
47+ const headers = new HttpHeaders ( { Authorization : 'Basic ' + btoa ( username + ':' + password ) } ) ;
48+ return this . httpClient . post < Employee > ( "http://localhost:8080/employees" , employee , { headers} ) ;
4249 }
43-
44-
45-
46- getHeaders ( ) {
47- let username = 'admin'
48- let password = 'password'
49-
50- let basicString = 'Basic ' + window . btoa ( username + ':' + password )
51- return basicString ;
52- }
53-
5450}
0 commit comments