Taha Taha - 4 months ago 15
Ajax Question

Unable to Get External JSON data in template in EmberJS

I've searched on this topic and have tried multiple things but so far have been unable to solve my problem, so I created an account so I can learn :)

I am learning EmberJS and I am unable to get JSON data from the route in EmberJS to output to the actual template. However a Javascript alert in the route presents the data.

I am calling a third-party API that gets WHOIS information for domains externally over http.

Example JSON output

"status": [
"clientTransferProhibited https:\/\/icann.org\/epp#clientTransferProhibited"
"updated_date": [
"contacts": {
"admin": null,
"tech": null,
"registrant": null,
"billing": null
"nameservers": [
"expiration_date": [
"creation_date": [
"raw": [
"\n Domain Name: APPLE.COM\n Registrar: CSC CORPORATE DOMAINS, INC.\n Sponsoring Registrar IANA ID: 299\n Whois Server: whois.corporatedomains.com\n Referral URL: http:\/\/www.cscglobal.com\/global\/web\/csc\/digital-brand-services.html\n Name Server: ADNS1.APPLE.COM\n Name Server: ADNS2.APPLE.COM\n Name Server: NSERVER.APPLE.COM\n Name Server: NSERVER2.APPLE.COM\n Name Server: NSERVER3.APPLE.COM\n Name Server: NSERVER4.APPLE.COM\n Name Server: NSERVER5.APPLE.COM\n Name Server: NSERVER6.APPLE.COM\n Status: clientTransferProhibited https:\/\/icann.org\/epp#clientTransferProhibited\n Updated Date: 04-dec-2012\n Creation Date: 19-feb-1987\n Expiration Date: 20-feb-2021"
"whois_server": [
"registrar": [
"CSC Corporate Domains, INC."

Here's my code.


import Ember from 'ember';

export default Ember.Route.extend({
titleToken: "MyTitle",
model() {
type: "GET",
url: "https://api.who.pm/apple.com",
dataType: "json",
success: function(jsonData) {
return jsonData;
error: function(request, status, error) {
console.log("Error! " + request.responseText);

In my
I have tried a variety of things to get the
output, however have not been successful. I have tried
, and a few other things. For now I am just trying to get the data output in the template.

The alert launches successfully when the page is run.

Any help would be greatly appreciated.
Thank you

Lux Lux

The model hook should return a promise or actual data, you return nothing.

The return jsonData returns the success function, not the model hook. By the time the success hook is called, the model hook already has returned.

I can just strongly recommend you to inform yourself about javascript functions, callbacks and closures. Also make sure you understand this and Promises.

For usage with jQuery you need to know that jQuery 2.x .ajax() will return a thenable, but this is not a promise. This is fixed in jQuery 3.x. So for now do use RSVP.resolve:

model() {
  return Ember.RSVP.resolve($.ajax({
    type: "GET",
    url: "https://api.who.pm/apple.com",
    dataType: "json",