xru*_*ics 6 api node.js postman
我必须在GET请求中发送id数组作为paramenter.如何在Postman中测试它(用于API测试的google chrome扩展)?
场景是我有网址,www.something.com/activity/poi_ids
poi_ids应该包含像[316,318]这样的id数组
在api一侧使用快递,
app.get('/activity/:poi_ids',function(req,res){
var poi_ids = req.params.poi_ids;
.......
.......
});
Run Code Online (Sandbox Code Playgroud)
您可以通过查询参数发送它们。在您的http查询参数中,将所有值分配给相同的变量,例如
GET activity?pid=12&pid=23&pid=34
Run Code Online (Sandbox Code Playgroud)
然后在你的快递里面得到像
var ids=req.query.pid; //[12,23,34]
Run Code Online (Sandbox Code Playgroud)
它是非结构化文本。如果你想“发送一个数组”,那么你需要设计某种方法对其进行编码,然后编写 JavaScript 对其进行解码。
例如:
GET /activity/316-318
Run Code Online (Sandbox Code Playgroud)
和
var poi_ids = req.params.poi_ids.split("-");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4270 次 |
| 最近记录: |