Skip to content

Instantly share code, notes, and snippets.

@NMZivkovic
Last active Oct 8, 2017
Embed
What would you like to do?
@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