Ionic showing API results in a list view

β€” 5 minute read


Today I wanted to check in on Ionic again, and specific making an API call and showcasing the results in a list.

This is a very common use-case in Ionic. You want to call an API endpoint and get a list of results back.

The user can often click these items and see the detail page. In our instance, we will just focus on showing the list for now.

The end result will look like this:

Ionic list

Ionic starting point permalink

A while ago, we created a basic Ionic app, which we will use as our template to work from.

If you're interested in getting started with Ionic, follow this article.

You can download the starting template from GitHub.

Creating our list component permalink

We will be using the default tabs to create our list in. Open up and insert the following HTML.

<ion-header [translucent]="true">
<ion-title> Tab 1 </ion-title>

<ion-content [fullscreen]="true">

If we render this it will look like this:

Ionic basic list

Now we will make this dynamic by doing a API call!

Adding an API call permalink

Now let's add an API so we can fetch some data to fill his list.

First let's enable the HttpClientModule in the app.module.ts.

imports: [
// Other imports

Now if we have the let's make a loadData function.

loadData(event = null) {
.get<{ data: any[] }>(``)
.subscribe((resp: { data: any }) => { =;

This will call our API and set the data of this component to be the object.

The rest of the component will look like this.

data: any[] = [];

constructor(private http: HttpClient) {}

ionViewWillEnter() { = [];

Now let's modify the actual

<ion-item *ngFor="let item of data">

When we run this it will look like this.

Ionic list

There we go, how cool right!

You can find this project on GitHub.

Thank you for reading, and let's connect! permalink

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter