I am hosting my json from my server with the domain name


#1

Hello All,

I am doing the blogger client application and I am hosting my json file from my server with domain name using this code App.Store = DS.Store.extend({ revision: 12, adapter: DS.RESTAdapter.extend({ host: ‘http://xyz.com/posts’ }) }); I got this error GET http://localhost/posts/1 404 (Not Found) jquery-1.9.1.js:8526 Error while loading route: Class {id: “1”, store: Class, _reference: Object, currentState: Object, _changesToSync: Object…} ember.js:415 Uncaught Error: Attempted to handle event loadedData on App.Post:ember268:1 while in state root.error. ember-data.js:4029 Uncaught App.Post:ember268:1


#2

You probably need to use namespace instead of host. See more here: http://emberjs.com/guides/models/connecting-to-an-http-server/#toc_url-prefix


#3

App.Store = DS.Store.extend({ revision: 12, adapter: DS.RESTAdapter.extend({ namespace: ‘http://domain.com/posts’ }) });

Like this??


#4

GET http://localhost/domain.com/posts/posts 404 (Not Found)

I got this error…when I did App.Store = DS.Store.extend({ revision: 12, adapter: DS.RESTAdapter.extend({ namespace: ‘domainxyz.com/posts’ }) });


#5
App.Store = DS.Store.extend({
  revision: 12,
  adapter: DS.RESTAdapter.extend({
  url: 'http://domain.com'
  namespace: 'rest/of/the/url/if/you/need/to'
 })
});

Ember data will add the server endpoint for the store you are looking for . So if your api is on the url http://domain.com and your go to your “posts” route it will look for http://domain.com/posts. Name space is used for a url like this “http://domain.com/rest/of/the/url/if/you/need/to/posts

So in your case you don’t need the namespace attribute.

Also something to check is the header on your json to allow for cross domain


#6

Thanks a lot for the reply, If I din’t use the namespace, I am getting 405 method is not allowed error…Do you have any working sample of the same type??


#7

Sorry i dont have any online app to show it. Are your app and api on the same server ? can you check the http request and what url ember uses to get the content ?


#8

No, my app is in localhost and the api is in my domain server. I tired this App.Store = DS.Store.extend({ revision: 12, adapter: DS.RESTAdapter.extend({ url: 'http://domain.com’ namespace: ‘rest/of/the/url/if/you/need/to’ }) });

I got this error XMLHttpRequest cannot load http://domain.com/posts/posts. Origin http://localhost is not allowed by Access-Control-Allow-Origin.