How to use any rest api(json) in Ember templates(hbs). I have a service deployed on apache tomcat and I want to use its response in ember js. I tried all the things available online but no luck.
Below is my code snippets;
-----------app\adaptors\application.js--------------------
import DS from 'ember-data';
import Ember from 'ember';
var App = window.App = Ember.Application.extend();
App.UserAdapter = DS.RESTAdapter.extend({
find: function(){
return Ember.$.getJSON('http://localhost:8082/emberTestService');
}
});
--------------routes\user.js----------------------
import Ember from 'ember';
var App = window.App = Ember.Application.extend();
App.UserRoute = Ember.Route.extend({
model: function(){
var adapter = App.UserAdapter.create();
return adapter.find();
}
});
-------------templates\application.hbs---------------
<h1>Welcome in app</h1>
Service http://localhost:8082/emberTestService returns { "name": "Tomcat" } and I want this response to return on my template.
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire