Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
33 lines (25 sloc) 1.17 KB
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { of } from 'rxjs/observable/of';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { catchError, map, tap } from 'rxjs/operators';
import {Headers, RequestOptions } from '@angular/http';
// Enviroment variables
import { environment } from '../../environments/environment';
// User list class
import { UserList } from '../user-list';
import { HandleErrorService } from './handle-error.service';
// check if the token is working...
import { AuthService } from './auth.service';
@Injectable()
export class UserlistService {
constructor(private http: HttpClient, public auth: AuthService, private handleError: HandleErrorService) { }
private mainUrl = environment.mainUrl + 'user-list?_format=json'; // URL to web api
getUserList(): Observable<UserList[]> {
const users = this.http.get<UserList[]>(this.mainUrl);
// const users = this.http.get<UserList[]>(this.mainUrl,
// { headers:new HttpHeaders().append('Authorization', `Bearer ${this.auth.getToken()}`)})
return users
.catch(this.handleError.handleError);
}
}