Hi I\'m trying to follow a tutorial on angular but the tutorial was made in September. I believe the person used angular-cli 1.3.2. I\'m not sure which version of rxjs he wa
In Angular 6x with rxjs 6.3.3 you can do this. In the file(app.component.ts)
import { Component } from '@angular/core';
import { HttpClient, HttpParams, HttpHeaders} from '@angular/common/http';
import { Observable, throwError } from 'rxjs';
import { map, catchError, retry } from 'rxjs/operators';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
_url = 'http://...';
constructor( private http: HttpClient ) { }
articles: Observable;
// Method to get info
getAPIRest() {
const params = new HttpParams().set('parameter', 'value');
const headers = new HttpHeaders().set('Autorization', 'auth-token');
this.articles = this.http.get(this._url + '/articles', { params, headers })
.pipe( retry(3),
map((data => data),
catchError(err => throwError(err))));
}
}