I'm working on an Ember website with a Node JS Express API. I'm using ember-ajax to connect to the API.
EDIT:
Ember version is 1.13
Ember Data : 1.13.15
The problem is Ember does the AJAX call as if it was directed towards localhost:4200 (Ember) when it should be sent towards localhost:9029 (Express). Of course, this throws a 404.
How do I make it so it sends the request to the API instead of itself? I've tried --pxy after ember s but that does not work. It seems like it's ignoring the files I created. I'm very new to Ember.
app/services/ajax.js
import Ember from 'ember';
import AjaxService from 'ember-ajax/services/ajax';
export default AjaxService.extend({
namespace: '/api',
host: 'http://localhost:9029',
trustedHosts: [
'http://localhost:9029',
]
});
app/routes/test.js
import Ember from 'ember';
import AjaxService from 'ember-ajax/services/ajax';
export default Ember.Route.extend({
ajax: Ember.inject.service(),
model() {
return this.get('ajax').request('/gimmieDatDate', {method: 'POST'});
}
});
Aucun commentaire:
Enregistrer un commentaire