[英]Not able to send put request with postman
what I am sending is 我发送的是
http://localhost:3000/accounts?user_id=62139fbf-ce6a-4827-8fe8-f1c3197bff82
// params
user_id 62139fbf-ce6a-4827-8fe8-f1c3197bff82
My Api in node Js inside account.js is 我在account.js中的节点Js中的Api是
router.route('/:user_id').put(function(req, res) {
console.log("hello")
It works when I change the route to the following( ie I remove the params user_id and also from the postman. 当我将路线更改为以下路线时(即,我删除了参数user_id并从邮递员中删除了它,它也起作用。
router.route('/').put(function(req, res) {
console.log("efwe")
So the problem is with sending params any help. 因此,问题在于向params发送任何帮助。
I believe your URL should be like - 我相信您的网址应该像-
http://localhost:3000/accounts/62139fbf-ce6a-4827-8fe8-f1c3197bff82 HTTP://本地主机:3000 /帐号/ 62139fbf-ce6a-4827-8fe8-f1c3197bff82
for route - router.route('/accounts/:user_id').
用于路由router.route('/accounts/:user_id').
For query parameters you need to do something like this - http://localhost:3000/accounts?user_id=62139fbf-ce6a-4827-8fe8-f1c3197bff82 对于查询参数,您需要执行以下操作-http:// localhost:3000 / accounts?user_id = 62139fbf-ce6a-4827-8fe8-f1c3197bff82
router.route("/accounts",function(req,res){
var id = req.query.user_id; // Check syntax for framework you are using
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.