javascript - NodeJS Express 递归路由
问题描述
某些网站的 API 允许您执行以下操作:
Initial user's id their first friend, also a user
v v
GET /api/users/54282/friends/0/friends/0
^
first item in array, would also be a user
而不是
Initial user's id
v
GET /api/users/54282/friends
Look at friends[0].id to get the first friend's id
First friend's id
v
GET /api/users/97420/friends
Look at friends[0].id to get the first friend's id
First friend's id
v
GET /api/users/31230
另一个例子虽然我不确定 Github 是否允许这样做
Get the 10th collaborator's repos
GET /api/users/sharedrory/repos/312388/collaborators/10/repos
你将如何在快递中实现这样的事情?
解决方案
推荐阅读
- flutter - 在 null 上调用 getter 'length' 在预先存在的 json 上调用
- html - 如何保持页面固定
- php - PHP DateTime::__construct():无法解析位置 8 (0) 的时间字符串:意外字符
- google-cloud-firestore - 结合 facebook 登录和正常注册的 firebase 规则
- python - 无法通过 windows 中的诗歌安装 torchvision
- python - 将特定 USB 设备(由产品 ID 和供应商 ID 标识)连接到系统后立即触发 python 脚本
- javascript - 如何与两个数组数据进行比较和更改?
- python - 如何使用fuzzywuzzy 获得此输出?
- android-studio - 在我的 android 应用程序中删除夜间模式 | 安卓工作室
- kubernetes - kubernetes中calico CNI如何找出每个节点分配了什么podcidr