There is a POST API set up through API Gateway on AWS, but it seems to be returning an infinite loop of arrays, as shown in the image below. How can I make it return just one array?
Below is the code snippet:
Angular
import { Component, OnInit, ViewChild, OnChanges, OnDestroy } from '@angular/core';
import { HttpClient } from '@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<> = new Subject<>();
constructor(public http:HttpClient) {}
@ViewChild(IonSlides,{'static':false}) slides: IonSlides;
slideOpts = {
initialSlide: 1,
speed: 400
};
public result:any
public res:any
data:Observable<>;
ata:Observable<>;
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>
</ion-slides>
</ion-card-content>
</ion-card>