# How can I load any json from my page?

**URL:** <https://discuss.emberjs.com/t/how-can-i-load-any-json-from-my-page/12601>\
**Category:** Uncategorized\
**Created:** [March 16, 2017, 12:07am UTC](https://discuss.emberjs.com/t/how-can-i-load-any-json-from-my-page/12601 "2017-03-16T00:07:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![GELight](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/gelight/32/12902_2.png) [@GELight](https://discuss.emberjs.com/u/GELight)\
**Post date:** [March 16, 2017, 12:07am UTC](https://discuss.emberjs.com/t/how-can-i-load-any-json-from-my-page/12601/1 "2017-03-16T00:07:16Z")

</div>

Hi,

I try to load a json file with an ember adapter + model but my json call failes with an error.

This is my code within my findRecord method in my application adapter: findRecord: function findRecord(store, type, id, snapshot) { return new Ember.RSVP.Promise(function (resolve, reject) {

```
    Ember.$.getJSON('/ui-page/index.json').then(function (data) {
      resolve(data);
    }, function (jqXHR) {
      reject(jqXHR);
    });    

```

 ![](https://us1.discourse-cdn.com/flex019/uploads/emberjs_public/original/2X/3/3a8e92c0e3a58d101e3b28db47c5faf9bc44bab1.png)

My json call is ever rejected … I need a little simple example that I can see what I do wrong.

I hope you can help me. Thanks,

Greetings, Mario

---

<div class="post-metadata">

**Author:** ![Elisha.Ebenezer](https://avatars.discourse-cdn.com/v4/letter/e/e36b37/32.png) [@Elisha.Ebenezer](https://discuss.emberjs.com/u/Elisha.Ebenezer)\
**Post date:** [March 16, 2017, 2:26pm UTC](https://discuss.emberjs.com/t/how-can-i-load-any-json-from-my-page/12601/2 "2017-03-16T14:26:51Z")

</div>

You should be using [ember-cli-mirage](http://www.ember-cli-mirage.com/) and configure the same to return your json.

You may also refer [Mocking a Blog Backend with Mirage and JSON API - Ember Igniter](https://emberigniter.com/mock-json-api-backend-with-mirage) as tutorial

---

<div class="post-metadata">

**Author:** ![skaterdav85](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/skaterdav85/32/18291_2.png) [@skaterdav85](https://discuss.emberjs.com/u/skaterdav85)\
**Post date:** [March 17, 2017, 12:29am UTC](https://discuss.emberjs.com/t/how-can-i-load-any-json-from-my-page/12601/3 "2017-03-17T00:29:17Z")

</div>

You can also place the JSON files in your public folder

---

<div class="post-metadata">

**Author:** ![GELight](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/gelight/32/12902_2.png) [@GELight](https://discuss.emberjs.com/u/GELight)\
**Post date:** [March 17, 2017, 8:22am UTC](https://discuss.emberjs.com/t/how-can-i-load-any-json-from-my-page/12601/4 "2017-03-17T08:22:45Z")

</div>

My json is placed in **public/ui-page/index.json**

Currently this is my simple test call: Ember.$.getJSON(‘/ui-page/index.json’).then(function (data) { resolve(data); }, function (jqXHR) { reject(jqXHR); });

The response ends ever in the catch ( rejected ) case. Why?

Mario

---

<div class="post-metadata">

**Author:** ![Elisha.Ebenezer](https://avatars.discourse-cdn.com/v4/letter/e/e36b37/32.png) [@Elisha.Ebenezer](https://discuss.emberjs.com/u/Elisha.Ebenezer)\
**Post date:** [March 17, 2017, 9:21pm UTC](https://discuss.emberjs.com/t/how-can-i-load-any-json-from-my-page/12601/5 "2017-03-17T21:21:09Z")

</div>

Your approach is deviating from standard guidelines, which may be due to insufficient understanding of Ember Routing mechanism.

Any contextual path in ember application is considered as route, and there is NO route definition for the mentioned path. Please refer [Core Concepts](https://guides.emberjs.com/v2.11.0/getting-started/core-concepts/) and [Routing](https://guides.emberjs.com/v2.11.0/routing/) in guides for better understanding.

As already mentioned, you should be using ember-cli-mirage with fixtures for your scenario.

if you still want to load index.json as static asset, you might want to place it under public folder.

HTH.

---

<div class="post-metadata">

**Author:** ![GELight](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/gelight/32/12902_2.png) [@GELight](https://discuss.emberjs.com/u/GELight)\
**Post date:** [March 18, 2017, 7:36pm UTC](https://discuss.emberjs.com/t/how-can-i-load-any-json-from-my-page/12601/6 "2017-03-18T19:36:52Z")

</div>

Hi… yes I know. This was only a test. Now I use an standard RSTAdapter with this call for example:

this.get(‘store’).findRecord(‘ui-page’, ‘index’);

My question now is: How must be the structure of my json file when my model looks so:

export default DS.Model.extend({ type: DS.attr(‘string’), children: DS.attr() });

Mario
