Hello, I normally get data from a service I created, a hard-coded JSON. But I need to take the JSON from an URL.
This is my twiddle :
How can I add a URL as a source instead of calling it from the service ‘pics’? I tried something but got errors and couldn’t do anything. I’m very new at this.
It’s not specifically shown, but is just discussed in passing in this text:
Typically, the model hook should return an Ember Data record, but it can also return any promise object (Ember Data records are promises), or a plain JavaScript object or array. Ember will wait until the data finishes loading (until the promise is resolved) before rendering the template.
Thanks for the response @acorncom , but this is what I tried before. I got this error :
Mirage: Your Ember app tried to GET 'my URL', but there was no route defined to handle this request. Define a route that matches this path in your mirage/config.js file. Did you forget to add your namespace?
Also I used return $.getJSON not return $.get.
About the error, I’m not really using mirage, I just created it at the beginning thinking I would use it but then I didn’t, when I delete the folder I get an error though. What am I supposed to do now? I tried to add things to the mirage’s config.js like
If you aren’t using Mirage at all, then I would delete it from your package.json file and remove the ember-cli-mirage folder from your npm_modules folder. That should then lead to your code working.
If you want to use Mirage for some routes, then you can setup a passthrough for some urls (details on the Mirage site).
I deleted it, but still I see a blank page with no errors. I can’t find out why. This is my new twiddle with the $.getJSON() function, can you please check it ? You can see it is all blank. It doesn’t fix it if I use https:// instead of http:// . Ember Twiddle
In your index.hbs, use : {{image-list model=model.Data currentPos=currentPos }}
You do not need models/*.js because you don’t use Ember-data when you get model() in your IndexRoute. And i think you should use http://api.donanimhaber.com/api/v1/site/NewsSite?pageIndex=0&pageSize=15’ and not https://api.donanimhaber.com/api/v1/site/NewsSite?pageIndex=0&pageSize=15 : https do not respond…
I checked the documentation , I guess I don’t need a serialization because the URL has the proper JSON data , but, I created an adapter called application, and wrote the URL in it like that :
Nothing has changed. There is no more info in the docs about adapters… I dont get the ember-data part, I never used it before. Also, should I bring back the models/ folder back for that? Because I deleted it according to your previous post. @Myrdhin