5.4: Retrieving Users from the Database
Adding Our API's Base Url to Environment Config
export const environment = {
production: false,
apiUrl: 'http://localhost:5000/api/' // <--- Added
};baseUrl = environment.apiUrl;login(model: any) {
return this._http.post<AuthUser>(this.baseUrl + 'auth/login', model, { headers: new HttpHeaders() // modified
.set('Content-Type', 'application/json') })
.map(user => {
if (user) {
localStorage.setItem('token', user.tokenString);
this.decodedToken = this._jwtHelperService.decodeToken(user.tokenString);
this.userToken = user.tokenString;
}
});
}
register(model: any) {
return this._http.post(this.baseUrl + 'auth/register', model, { headers: new HttpHeaders() // modified
.set('Content-Type', 'application/json')
});
}Adding a User Service
Display Users in the MemberListComponent

Last updated