Looking for guidance on how to integrate a REST API (providing JSON data) into Ember templates (hbs). I have a service hosted on Apache Tomcat and I'm struggling to utilize its response in Ember JS. Despite trying various approaches found online, I haven't had any success.
Here are snippets of my code:
-----------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>
{{log 'Name is:' name}}
{{name}}
When calling the service at http://localhost:8082/emberTestService, it returns { "name": "Tomcat" } and I aim to display this response in my template.
Appreciate any help in advance.