I'm trying to access an API and hitting a brick wall...repeatedly. I've read through the Angular documentation but I'm still missing something. Please advise. Thank you!
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { map, catchError, tap } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
})
export class RestService {
private url = 'https://api.com';
private auth = ('xxxx:xxxx');
httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'Content-Encoding': 'none',
'Authorization': 'Basic' + btoa(this.auth)
})
};
constructor(private http: HttpClient) {
}
index() {
return this.http.get<any[]>(this.url, this.httpOptions);
}
}