Skip to content

Instantly share code, notes, and snippets.

@NMZivkovic
Last active October 8, 2017 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NMZivkovic/2ed96353c3f4970c589663732cfaaa58 to your computer and use it in GitHub Desktop.
Save NMZivkovic/2ed96353c3f4970c589663732cfaaa58 to your computer and use it in GitHub Desktop.
@Injectable()
export class UserService {
constructor(private http: Http) {
}
getUsers(searchCriteria:any) : Observable<User[]>{
let params: URLSearchParams = new URLSearchParams();
params.set('name', searchCriteria);
return this.http.get("http://localhost:3000/getUsers", { search: params })
.map((res:any) => {
return res.json();
})
.catch((error:any) => {
return Observable.throw(error.json ? error.json().error : error || 'Server error')
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment