first test is returning array json data
second and Third is just restun json data
======== sample source ===========
var express = require('express');
var app = express();
app.get('/school', function(req,res){
res.send([{bus:'bus1'}, {bus:'bus2'}]);
});
app.get('/school/:number', function(req, res){
res.send({id:'two path', number:req.params.number});
});
app.get('/school/:number/:destination', function(req, res){
res.send({id:'three path', destination:req.params.destination});
})
app.listen(3000);
console.log('Listen on port 3000......');
and result list
1. http://192.168.123.165:3000/school
[
{
"bus": "bus1"
},
{
"bus": "bus2"
}
]
{
"bus": "bus1"
},
{
"bus": "bus2"
}
]
2. http://192.168.123.165:3000/school/second
{
"id": "two path",
"number": "second"
}
3. http://192.168.123.165:3000/school/third
{
"id": "three path",
"destination": "third"
}
No comments:
Post a Comment