Struggling with a problem in EmberJS and unable to find a solution despite trying various methods. I am diving deep into learning this, hence created an account to seek assistance :)
The issue lies in fetching JSON data from the route in EmberJS and displaying it in the template. Surprisingly, the data is displayed successfully through a JavaScript alert in the route.
My task involves utilizing a third-party API to extract WHOIS information for domains via http.
Provided below is a snippet of the example JSON output:
{
"status": [
"clientTransferProhibited https:\/\/icann.org\/epp#clientTransferProhibited"
],
...
}
Presenting my current code:
routes/file.js
import Ember from 'ember';
export default Ember.Route.extend({
titleToken: "MyTitle",
model() {
$.ajax({
type: "GET",
url: "https://api.who.pm/apple.com",
dataType: "json",
success: function(jsonData) {
alert(JSON.stringify(jsonData));
return jsonData;
},
error: function(request, status, error) {
console.log("Error! " + request.responseText);
}
});
}
});
Despite numerous attempts in templates/file.hbs
to display the jsonData
, I haven't been successful. Tried variations like {{model}}
, {{model.data}}
, among others. The main goal right now is to showcase the data within the template itself.
The page triggers the alert successfully upon loading.
Any assistance on this matter would be highly valued. Thank you!