user1082754
user1082754

Reputation:

Getting started with Backbone and a RESTful API

In Backbone, I have a User model:

var User = Backbone.Model.extend({
  url: '/api/user'
});

Next, I instantiate a user object:

var user = new User({ id: "123" });

Then I call:

user.fetch();

Upon inspection of the networks pane in Web Inspector, it appears that an API call is being made to /api/user when calling the fetch method on user. My question is simply this: should I not expect it to make an API call to /api/user/123?

Upvotes: 1

Views: 877

Answers (1)

KeesDijk
KeesDijk

Reputation: 2329

You are using a model outside of the collection, so you need to set the urlroot

http://backbonejs.org/#Model-url

Upvotes: 4

Related Questions