H
H
hatealleverything2020-06-29 17:27:46
Node.js
hatealleverything, 2020-06-29 17:27:46

Express Handle Bars. How can I get only 1 element from the database in index.hbs?

Good afternoon. Sorry in advance for the wrong question. I am new to node.js in general. The essence of the question is that I need to pull out only 1 element of the array from the database.

Here is the source. The database outputs everything fine with this. Syntax issues.

<h3>Index page</h3>

{{#each items}}
    <ul class="table">
        <li>ID = {{id}}</li>
        <li>Title = {{title}}</li>
        <img src="{{img}}" alt="">
        <li>Price = {{price}}</li>
        <li>Type = {{type}}</li>
        <li>Chance = {{chance}}</li>
    </ul>
{{/each}}


I tried to output as in JavaScript, for example, the 5th element of the array. Outputs errors.

<h3>Index page</h3>

{{#each items}}
    <ul class="table">
        <li>ID = {{id[5]}}</li>
        <li>Title = {{title[5]}}</li>
        <img src="{{img[5]}}" alt="">
        <li>Price = {{price[5]}}</li>
        <li>Type = {{type[5]}}</li>
        <li>Chance = {{chance[5]}}</li>
    </ul>
{{/each}}


Is it possible to do this at all? I thought about trying to do it somehow through if, but maybe there is an easier way?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question