node做client和java中间层的http通信 是这样写?
var usr=require(‘dao/dbConnect’); var express = require(‘express’); var router = express.Router(); var request = require(‘request’); /* GET home page. */ router.get(’/’, function(req, res) { res.render(‘index’); }); router.get(’/news’, function(req, res) { res.render(‘news’); }); router.post(’/list’, function(req, res) { request(‘http://x.x.x.x:8080/cms/f/list?categoryId=15’,function (error, response, body) { if (!error && response.statusCode == 200) { console.log(typeof body) res.json(JSON.parse(body).result.list) } }) });
module.exports = router;