Reputation: 406
I have a user controller method like:
create: function( req, res ){
res.json({name:"Cool Name"});
}
But when use this
socket.post("/user/create", {
myName: "John Doe"}, function(r){ console.log(r) });
I get an error message "Forbidden" with status code 500. Its working fine when I make normal post request. Can you please throw some light on this.
Upvotes: 3
Views: 901
Reputation: 24948
You are posting to /user/create
, which is the "shortcut" create URL. Shortcuts are accessed with the GET
method (and should generally be turned off in production). To create a user via POST
, use the /user
URL:
socket.post("/user", {myName: "John Doe"}, function(r){ console.log(r) });
Upvotes: 2