Reputation: 1460
I'm new to Ember CLI and have been trying to get the ember cli server to proxy requests to my Rails backend with no success.
I have Ember CLI v.0.39 installed, and have put up a route to fetch a model from the server by AJAX:
return Em.$.getJSON('/users').then(function(result){
return Em.A(result);
)};
I run ember s --proxy "http://127.0.0.1:3000"
this being my Rails endpoint.
The request is being made from the browser, but I find no trace of it being forwarded to the Rails endpoint. The javascript console mentions a bug about an 'Route: undefined' error,
I have also found info on the web that v.0.39 had some problems in this regard and have fetched and npm link
-ed the latest version from the git ember-cli rep.
Error while loading route: undefined
I do think that the error message is strictly a result of the AJAX response being void.
Any ideas would be greatly appreciated.
Upvotes: 2
Views: 1571
Reputation: 876
Using master, this works fine for me. There are a couple syntax issues with your example though. Your route should look something like this:
import Ember from 'ember';
export default Ember.Route.extend({
model: function() {
return Ember.$.getJSON('/users').then(function(result){
return Ember.A(result);
});
}
});
A couple things that might help:
http://localhost:4200
npm link
in your clone of ember-cli and also ran npm link ember-cli
from you ember-cli app directory.Upvotes: 3