Closed markeilander closed 7 years ago
There is a baseRoute option already implemented:
I know it would be easier to set a baseUrl then have baseRoute added but you can easily create a global var that includes it then include that into your baseRoute when settings up each model.
You can see it in use here:
Model.prototype.getRoute = function(action) {
var baseRoute = action.baseRoute || this.settings.baseRoute;
return this.interpolate(baseRoute + action.route);
}
It is specified here: https://github.com/aarondfrancis/vue-model/blob/a06a65e1f21171fd47fcc5453894937f58a0d861/src/ModelDefaults.js#L12
Hi there,
I have some changes in the pipeline to enhance the API endpoint support. In the most cases API endpoints look like this https://your.tld/ressources
or https://your.tld/api/ressources
. So there is a need to configure each model endpoint with an information that is (possibly) already there - the resource name (type
in the code context). RESTful APIs use the plural of the resource name e.g. users
for the user
model.
To follow the paradigm convention over configuration
I will set the route for an action with the plural of the resource name (type
) like e.g. for create:
create: {
method: 'POST',
route: '/{_type_plural}',
}
With this it's easy to support multiple resources for one API without the need of configuring each resource route. The baseRoute
can then be used for an optional namespace prefixing for an API path like /api/v1
.
Feedback is welcome!
Hi There,
My compliments for this nvery nice package.
Just one question: is the a way to set de basy URL for mij api (eg. https://somedomain.com/api/).
+1 for the other two open issues (replace jquery with vue-resource and result caching)