Coder Social home page Coder Social logo

Comments (7)

milroyfraser avatar milroyfraser commented on August 26, 2024 1

Hi @subotkevic thank you very much for constructive comments.
Fixed on 0.3.9 ✌️

from sarala.

subotkevic avatar subotkevic commented on August 26, 2024

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.

subotkevic avatar subotkevic commented on August 26, 2024

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.

subotkevic avatar subotkevic commented on August 26, 2024

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.

subotkevic avatar subotkevic commented on August 26, 2024

Well, thank you for resolving this issue.

Not an issue though, but now it will be much more reusable.

from sarala.

subotkevic avatar subotkevic commented on August 26, 2024

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.

milroyfraser avatar milroyfraser commented on August 26, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.