Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个用户控制器方法,例如:
create: function( req, res ){ res.json({name:"Cool Name"}); }
但是当使用这个
socket.post("/user/create", { myName: "John Doe"}, function(r){ console.log(r) });
我收到一条错误消息“禁止”,状态码为 500。当我发出正常的发布请求时,它工作正常。您能否对此有所了解。
您正在发布到/user/create,这是“快捷方式”创建 URL。使用该方法访问快捷GET方式(通常应在生产中关闭)。要通过 创建用户POST,请使用/userURL:
/user/create
GET
POST
/user
socket.post("/user", {myName: "John Doe"}, function(r){ console.log(r) });