# How to get and iterate questions in ember from database

**URL:** <https://discuss.emberjs.com/t/how-to-get-and-iterate-questions-in-ember-from-database/18983>\
**Category:** Questions\
**Created:** [July 9, 2021, 7:30am UTC](https://discuss.emberjs.com/t/how-to-get-and-iterate-questions-in-ember-from-database/18983 "2021-07-09T07:30:01Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![ef4](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/ef4/32/13470_2.png) [@ef4](https://discuss.emberjs.com/u/ef4)\
**Post date:** [July 9, 2021, 2:19pm UTC](https://discuss.emberjs.com/t/how-to-get-and-iterate-questions-in-ember-from-database/18983/2 "2021-07-09T14:19:02Z")

</div>

If you haven’t already done it, the biggest piece of work here is exposing your data on an API endpoint. Same as we discussed in [How to connect mySQL and emberJS framework to send and retrieve data](https://discuss.emberjs.com/t/how-to-connect-mysql-and-emberjs-framework-to-send-and-retrieve-data/18910).

To load and display the list of questions, the simplest solution is to load the data from your route:

```nohighlight
// app/routes/my-page.js
import Route from '@ember/routing/route';
export default class extends Route {
  async model() {
    let response = await fetch('/your-questions-endpoint-here');
    let json = await response.json();
    return json;
  }
}

```

And then display it in the template like:

```nohighlight
{{!-- app/templates/my-page.hbs --}}
{{#each @model as |question|}}
<tr>
  <td>{{question.qid}}</td>
  <td>{{question.questionmessage}}</td>
</tr>
{{/each}}

```

---

_[View the full topic](https://discuss.emberjs.com/t/how-to-get-and-iterate-questions-in-ember-from-database/18983)._
