Comments (7)
Hi @subotkevic thank you very much for constructive comments.
Fixed on 0.3.9 ✌️
from sarala.
Or maybe we should be able to define or override that URL in the model itself somehow?
But the best solution would be to have default self URL, which is the same in 99% of the time.
from sarala.
Currently I have temp solution from client side:
In my base model I just implemented update()
method like this:
update() {
return this.makePersistRequest({
url: this.resourceUrl() + this.data().id,
method: 'PUT',
data: this.serialize(this.data())
})
}
So basically the same method just with different url
element.
from sarala.
More news... Looks like _delete()
method using self URL the same way, so currently I came across with something like this in my Base Model:
update() {
this.buildSelf()
super.update()
}
_delete() {
this.buildSelf()
super._delete()
}
buildSelf() {
const self = this.resourceUrl() + this.data().id
if (this.hasOwnProperty('links')) {
if (! this.links.hasOwnProperty('self')) {
this.links.self = self
}
} else {
this.links = { self }
}
}
from sarala.
Well, thank you for resolving this issue.
Not an issue though, but now it will be much more reusable.
from sarala.
By the way,
I checked your commits on that, and I can tell you that approach is good, but you forgot to handle the case when api will provide self url, so I think you need to additionally check for self url in the model, and if it does not exist, then use current approach.
Or, we need to have some setting in each model or just in base model which will define how user will want to use self urls - default, or from the response.
from sarala.
@subotkevic Thanks for the input.
Sarata expects api to follow {JSON:API} Recommendations. In that case this is always the same.
But I agree with your point, as an improvement we can check it before generate it.
from sarala.
Related Issues (20)
- Can't resolve 'sarala' HOT 2
- Support Fetching Relationships
- Support Include Parameters
- Support String Based Filter Parameters
- Use self url if available before generating.
- Support to configure multiple media types
- ETag support
- Urgent! Request structure BAD when updating resource's relationships HOT 2
- Have to access relation through .data? HOT 2
- Headers HOT 1
- how to POST with relationship HOT 5
- PATCH: Way to include only modified attributes in request body.
- API Documentation missing HOT 4
- Can't resolve 'babel-runtime/helpers/asyncToGenerator' HOT 1
- Set a customized property in Model subclass will affect the other. HOT 1
- Support for Typescript (d.ts) HOT 1
- No Support for Persist Requests with No Content HOT 2
- Invalid Method of Updating Relationships
- Empty or invalid date passed to server
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sarala.