0

BackboneJS webservice default urls are in this format:

/entities GET fetch entities

/entities/id GET get entity

I have a RESTful webservice that expects url in this format:

/entities?id=n

is there a simple way to force backbone to use this format?

Community
  • 1
  • 1
salgua
  • 698
  • 2
  • 10
  • 22

1 Answers1

1

Within your model, override the urlRoot property.

urlRoot: "/entities?id="

Alternatively, you can override url to take more control. (You will have to expand on this)

url: function() {
   return "/entities?id=" + this.id;
}
Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
  • I'm sorry, I already tried this, but it doesn't work. In this way, it generates an url like "/entities?id=/3", where "3" is the model id value. – salgua Mar 04 '13 at 08:51