Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
fix(users): use users/{id} API for getUserByUserId
Browse files Browse the repository at this point in the history
  • Loading branch information
pmuir authored and joshuawilson committed Mar 13, 2017
1 parent 49a80a5 commit 478850f
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/app/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,11 @@ export class UserService {
* @param userId the userId to search for
*/
getUserByUserId(userId: string): Observable<User> {
return this.getAllUsers().map(val => {
for (let u of val) {
if (userId === u.id) {
return u;
}
}
return null;
});
return this.http
.get(`${this.usersUrl}/${userId}`, { headers: this.headers })
.map(response => {
return response.json().data as User;
});
}

/**
Expand Down Expand Up @@ -136,8 +133,7 @@ export class UserService {
return this.http
.get(this.usersUrl, { headers: this.headers })
.map(response => {
this.allUserData = response.json().data as User[];
return this.allUserData;
return response.json().data as User[];
})
// TODO remove this
.do(val => this.allUserData = val);
Expand Down

0 comments on commit 478850f

Please sign in to comment.