I am brand new to using Ember. Right now, my main goal is to connect to an API that provides random text and then show that text on a webpage. The specific API endpoint I am using is "" which will give back a response in JSON format.
app/controllers/randomtext.js
import Ember from 'ember';
export default Ember.Controller.extend({
ajax: Ember.inject.service(),
actions: {
sendRequest() {
return this.get('ajax').request('http://www.randomtext.me/api/lorem/ul-5/5-15');
}
}
});
The XHR request is successful, and the correct JSON object is being returned as I can verify in the Chrome developer tab.
This is my app/templates/randomtext.hbs
<h1>Random Text</h1>
<p>test</p><button {{action "sendRequest"}}>testing</button>
Clicking the button triggers the xhr request successfully. However, I am unsure how to access the text_out property of the JSON response or display any part of it. Can someone provide a simple tutorial on how to make a GET request to an external API endpoint and showcase the response on a webpage within my ember application?