I want to pass json data that I get from an API into an array and display that information in my template and I don't know how to do that.
this error apears on my console :
my ts file :
this.api.getJoursFeries(year).subscribe(
(data: feries[]) => {
this.joursFeries = data;
// console.log(data);
}, (error: HttpErrorResponse) => {
console.log(error);
}
)
my service file :
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { feries } from '../models/feries';
@Injectable({
providedIn: 'root'
})
export class ApiService {
private apiBaseUrl = 'https://calendrier.api.gouv.fr/jours-feries/metropole'
constructor(private http: HttpClient) { }
getJoursFeries(annee : number): Observable<feries[]> {
return this.http.get<feries[]>(`${this.apiBaseUrl}/${annee}.json`);
}
}