samedi 23 mai 2020

Ember - Displaying API response data on Template.hbs

I'm very new to Ember - highly appreciated if anyone can assist. I need to display the network request response:

This is my port route:

import Route from '@ember/routing/route';

export default Route.extend({
    model(params) {
        this.store.findRecord('node', params.node_id).then((res) => {
            var port = res.ports.arrangedContent.currentState;
            console.log(port);
            return port;      
        });
    }
});

Here is the port model:

import DS from 'ember-data';

var ports = {
    label: DS.attr('string'),
    mode: DS.attr('string'),
    node_name: DS.attr('string'),
    port_csid: DS.attr('string'),
    proxied_ssh_url: DS.attr('string'),
    web_terminal_url: DS.attr('string'),
    runtime_status: DS.belongsTo('nodeRuntimeStatus', {async: false}),
    parent: DS.belongsTo('node', {async: false}),
};

export default DS.Model.extend(ports);

below is the template:


    <span>
       
    </span>

API call happens and I can console.log the ports (array) but no sure why I get nothing to display.




Aucun commentaire:

Enregistrer un commentaire