I am creating an Ember application with a WordPress back end. I have a model called menu.
import DS from 'ember-data';
export default DS.Model.extend({
});
I am using the ember-wordpress add on, this creates a name space of
wp-json/wp/v2/
For my api calls.
I want to query WordPress for my menu which has the end point
"http://localhost:8888/ember-wp/wp-json/wp-api-menus/v2/menus/"
I am extending the WordPress add on adapter and attempting to set a URL with the urlForFindRecord hook so I can change the URL used when attempting to use findRecord in my route.
My adapter is named menu-adapter
import WordPressAdapter from 'ember-wordpress/adapters/wordpress';
export default WordPressAdapter.extend({
namespace: 'api/v1',
urlForFindRecord() {
return `/wp-api-menus/v2/`;
}
});
And then my route is
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return Ember.RSVP.hash({
project: this.store.findAll('project'),
menu: this.store.findRecord('menu', 2)
});
}
});
However I get the error
http://localhost:8888/ember-wp/wp-json/wp/v2/menus/2 returned a 404
Which looks like it's not setting the URL correctly, I am not sure where I am going wrong.
Aucun commentaire:
Enregistrer un commentaire