Reputation: 7181
So I just finished making a fully RESTful JSON API for a User in node. When you visit http://localhost:8080/user/create
you get what you would normally expect- a new User which is then stored in a database, in my case mongoDB.
{
"createdAt": Date(),
"updatedAt": Date(),
"id": 1
}
My experience lies in server-side programming but I'm trying to get into Backbone.js. Can anyone point me in the right direction or show me how to create a very simple Backbone User Model and View for registering a User?
Upvotes: 0
Views: 752
Reputation: 8293
Firstly, Backbone has a REST API, you only need 1 URL to do all the REST actions (GET, POST, PUT, DELETE, [PATCH]). So if you need more than POST request, you may want to consider changing user/create to user only as it wouldn't make sense for the other type of requests.
Now for the code, based on this form:
<div id="form">
<input type="text" id="username" />
<button id="post">Send</button>
</div>
Here is the full example I made to create a user with an input. Pretty simple, ask for more precisions if you need.
Upvotes: 3