node.js - node 中 get怎么写传参函数

查看:173
本文介绍了node.js - node 中 get怎么写传参函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

node 中 get怎么写传参函数
http://demo.com/todos/id/56fbc659ebcb7d00519d6967
列出这个id下的数据
要实现这样的url函数要怎么写

//这样是指向http://demo.com/todos/
router.get('/', function(req, res, next) {
        
});

解决方案

router.get('/id/:id', function(req, res, next) {
    var id = req.params.id;
    console.log(id);
});

这篇关于node.js - node 中 get怎么写传参函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆