Closed jarekskuder closed 5 years ago
You can use the optional parameter collectionPath
to tell devour where to find your resource ie:
Api.define('Country', {
_id: '',
name: '',
comment: '',
iso2: '',
isDeleted: true,
createdAt: '',
modifiedAt: '',
createdBy: {
jsonApi: 'hasOne',
type: 'User'
},
modifiedBy: {
jsonApi: 'hasOne',
type: 'User'
}
}, {
collectionPath: 'countries'
});
Devour will now make requests to /countries when talking to the Country
model. So this should work:
Api.one('Country', this.props.match.params.id).patch({
_id: this.props.match.params.id,
name: this.state.country.name,
iso2: this.state.country.iso2,
comment: this.state.country.comment,
isDeleted: this.state.country.isDeleted,
modifiedAt: now.toISOString()
});
Thank you, it worked! :)
Hi,
i define model like this:
As i understand, if my API response has type: "Country", i must define it like that.
This is my backend API:
To get list of countries, i call it like this:
I really don't understand why i must write in findAll the URL and not model, but ok, atleast it works.
Now comes the fun part. When i want update or patch or create, example:
OR
I get this:
Error: API resource definition for model "countries" not found. Available models: Country
But when i write:
OR
Devour client builds and tries to call PATCH /Country/{id} but gets 404 error back, since the actual URL is /countries/{id} (as per REST standard?). Can someone help? I'm going crazy about this and can't figure it out...