Reputation: 125
I'm trying to get all data of one table and do an Excel of it. I have several problems. I'm using Restangular in my services. I did a getAll function in quotation.service.ts
getAll(): Observable<Quotation[]> {
return this.rg.all('quotations').getList();
}
And when I try to get it I do this in my component.ts:
exportAsXLSX(): void {
this.quotationService.getAll()
.subscribe(quotations => this.quotations = quotations);
//console.log(this.quotations);
}
When I try to access this.quotations it is undefined. I then tried:
exportAsXLSX(): void {
this.quotationService.getAll()
.subscribe(quotations => console.log(quotations ));
//console.log(this.quotations);
}
I get a result but I only get 30 results max when I want all of my rows (~1400) to do the Excel. I don't understand why I only get only 30 results and why when I try to access this.quotations
, it is undefined.
EDIT: So the 30 max results was indeed because of the API. But I still have the problem where
console.log(this.quotations);
is undefined, when I can check that quotations is the right data that I'm looking for.
The data from postman is something like this but I won't put everything since there is private data:
{
"data": {
"@context": "/api/contexts/Quotation",
"@id": "/api/quotations",
"@type": "hydra:Collection",
"hydra:member": [
{
"@id": "/api/quotations/1",
Upvotes: 0
Views: 114
Reputation: 125
Okay I finally got it. I used
@Input() quotations: Quotation[];
in my component.ts when I should have used
quotations: Quotation[];
Works fine now.
Upvotes: 0