Its a POST API created by API Gateway from AWS, however it always returns infinite repetition of arrays as you see in the below picture. How to return only one array?
Here's the code
Angular
import { Component, OnInit, ViewChild, OnChanges, OnDestroy } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { GetService } from '../get.service';
import { Observable, Subject } from 'rxjs';
import { IonSlides, IonSlide } from '@ionic/angular';
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
export class HomePage implements OnInit {
protected ngUnsubscribe: Subject<void> = new Subject<void>();
constructor(public http:HttpClient) {}
@ViewChild(IonSlides,{'static':false}) slides: IonSlides;
slideOpts = {
initialSlide: 1,
speed: 400
};
public result:any
public res:any
data:Observable<any>;
ata:Observable<any>;
ngOnInit(){
}
getdata(){
this.ata=this.http.post("XXXXXXXXXXXXXXXXXXXXXXXXX",{"freq":1});
this.ata.subscribe(data=>{console.log(data)})
return this.res
}
INDEX:any
slideChanged() {
this.INDEX =this.slides.getActiveIndex().then(data=>console.log(data))
return this.INDEX
}
}
HTML
<ion-header>
<ion-toolbar>
<ion-title>
Ionic Blank
</ion-title>
</ion-toolbar>
</ion-header>
<p *ngFor="let a of getdata()">{{a}}</p >
<ion-card>
<ion-card-content>
<ion-slides [options]="slideOpts" (ionSlideWillChange)="slideChanged()">
<ion-slide >
<h1></h1>
</ion-slide>
s
</ion-slides>
</ion-card-content>
</ion-card>