Skip to content

Commit 2401407

Browse files
committed
change 1
1 parent 2b41bdf commit 2401407

3 files changed

Lines changed: 70 additions & 9 deletions

File tree

codecamp-front/src/app/components/profile/profile.component.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@ import { Router } from '@angular/router';
99
})
1010
export class ProfileComponent implements OnInit {
1111

12-
user:Object;
12+
user: Object;
1313
constructor(
1414
private authService: AuthService,
1515
private router: Router
16-
) { }
16+
) {
17+
this.user = authService.getprofile().subscribe(profile => {
18+
this.user = profile.username;
19+
});
20+
console.log(this.user);
21+
}
1722

1823
ngOnInit() {
1924
}

codecamp-front/src/app/services/auth.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class AuthService {
2828
}
2929

3030
loadToken() {
31-
this.authToken = localStorage.getItem('token');
31+
this.authToken = localStorage.getItem('token');
3232
console.log(this.authToken); // Get token and asssign to variable to be used elsewhere
3333
}
3434
registerUser(user) {
@@ -59,4 +59,7 @@ export class AuthService {
5959
this.user = null; // Set user to null
6060
localStorage.clear(); // Clear local storage
6161
}
62+
getprofile() {
63+
return this.http.get(this.domain + '/users/profile').map(res => res.json());
64+
}
6265
}

package-lock.json

Lines changed: 59 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)