I want to slice the the json array in Angular which looks like this below.
And the code is below
export class AppComponent {
color: string = 'green';
public stocklist = [];
public objectKeys = Object.keys;
constructor() {
let url = 'http://localhost:8080/stocks';
axios.get(url).then(res =>{
this.stocklist = res.data.result[0].slice(0,10);
console.log(this.stocklist);
})
}
}
But it always shows res.data.result[0].slice is not a function, but we can see res.data.result[0] is literally a json array which can iterate in using *ngFor.
So which shold i use for slicing the json arry.
axiosin angular, change tohttpClient