Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

385
Views
How to get and display data from Strapi 4 using Akita Entity Service?

What I want to do: I'm trying to fetch data from my strapi api and display it.

What I'm working with: I'm working with Angular, Strapi (v4) and Akita, which I'm all completely new to and I'm using akita entity service.

Fetching the data works, but I can't display it. The collection type I'm trying to display is called question and has the the attribute name. There are 3 questions.

This is my component file:

export class HomePage {

  public questions$: Observable<Array<Question>> | undefined;

  constructor(
    protected readonly questionsService: QuestionsService,
    protected readonly questionsQuery: QuestionsQuery,
  ) {
     this.questionsService.get()
          .subscribe(console.log); 
     this.questions$ = this.questionsQuery.selectAll();
  }
}

This is my html file. Here I want to display the question by accessing the name attribute:

<ng-container *ngIf="(questions$ | async) as questions">
    <p *ngFor="let question of questions; let i = index;">
       Index: {{ i }} -
       Question: {{ question }} -
       id: {{ question.id }}
       <!--{{ question.attributes.name }} DOES NOT WORK.. Error Message: ERROR TypeError: Cannot read properties of undefined (reading 'name')-->
    </p>
</ng-container>

This is what my question model looks like (I feel like here is the problem):

export interface Question {
   id?: number;
   attributes: {
        name: string;
   };
}

This is what I see in my frontend:

Index: 0 - Question: [object Object],[object Object],[object Object] - id:
Index: 1 - Question: [object Object] - id:

It seems like all three questions are in the first index of the array. The data I get from the api looks like this: data response from api

So it seems like the data property is in the first index of the array and the meta array is in the second one. But I don't know what to do about it. Any Ideas? What I tried: change the model, but it didn't have any effect.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!