i have a http get request in my angular app, it looks like :
getAll():Observable<TransaksiDetail[]>{
return this.http.get<TransaksiDetail[]>(`${BASE_API()}/transaksi`, this.httpOptions);
}
then i run ng serve
the app is running well but in cmd it's showing an error like:
webpack: Compiled successfully. ERROR in src/app/services/transaksi.service.ts(56,5): error TS2322: Type 'Observable>' is not assignable to type 'Observable'. Type 'HttpEvent' is not assignable to type 'TransaksiDetail[]'. Type 'HttpProgressEvent' is not assignable to type 'TransaksiDetail[]'. Property 'includes' is missing in type 'HttpProgressEvent'.
and i try to access the page who call getAll() method and it's running well too
this is my class :
export class TransaksiView {
nama_pembeli:string;
id_toko:number;
nama_toko:number;
jumlah_beli:number;
total_harga:number;
status:string;
}
export class DetailTransaksiView {
id_menu: number;
id_size: number;
size: string;
topping: string;
jumlah: number;
harga_sekarang:number;
total_harga:number;
}
export class TransaksiDetail {
transaksi:TransaksiView;
detail:DetailTransaksiView[];
constructor(){
this.detail = new Array<DetailTransaksiView>();
}
}
this is my httpoption code
let opt = {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
'Authorization' : '',
}
if(this.storage.isStorageAvailable()){
let data = this.storage.retrieve('user_auth');
if(data){
opt.Authorization = `Bearer ${data.token}`;
}
}
this.httpOptions = { headers: new HttpHeaders(opt) };
what makes the error?