Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4830

REST Api does'nt work

$
0
0

@Nar_Zantaria wrote:

Hi people!

I“m learning ember and have troubles with REST api. I“ve read docs, but I just can’t understand, how it works. It’s really a problem, and I’d like to ask experiences people, and I would be very grateful for any help.

I just need to understand the principle of how it works.

In China, when kung-fu masters teach their students, they say “do as I do”. So, show me please how you do it!

So, we have two routes in Laravel backend, that return JSON.

Here is response of index (/) route:

{
    "responce":[
        {
            "id":0,
            "title":"main",
            "content": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Vitae, aliquam."
        },
        {
            "id":1,
            "name":"about",
            "content": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Provident, obcaecati? Accusantium ex dolorum voluptate deleniti?"
        },
        {
            "id":2,
            "name":"contacts",
            "content": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptates voluptatibus exercitationem molestias rem."
        }
    ]
}

And here is response of posts (/posts) route:

{
    "posts":[
        {
            "id":0,
            "name":"First",
            "content": "Lorem ipsum dolor sit amet consectetur adipisicing."
        },
        {
            "id":1,
            "name":"Second",
            "content": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Architecto quas quia distinctio ex consequuntur."
        },
        {
            "id":2,
            "name":"Third",
            "content": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Ullam, similique. Voluptatum, libero sequi."
        }
    ]
}

In Ember we have routes “index” and “posts”. I suppose there must be some kind of loop that processes the received data and outputs it.

The result on the index page should look something like this:

<!--
Index page in Ember
-->

<h3>main</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Vitae, aliquam.</p>

<h3>about</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Provident, obcaecati? Accusantium ex dolorum voluptate deleniti?</p>

<h3>contacts</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptates voluptatibus exercitationem molestias rem.</p>

And on the posts client page:

<!--
Posts page in Ember
-->

<h3>First</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing.</p>

<h3>Second</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Architecto quas quia distinctio ex consequuntur.</p>

<h3>Third</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Ullam, similique. Voluptatum, libero sequi.</p>

What Ember elements should be involved in this, how it all communicates and works?

I really have not found any demonstrative examples on the Internet that show the whole chain.

If I saw all this, I would immediately understand. Great thanks in advance! (excuse me my french)

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4830

Trending Articles