chunk在nodejs中的体现

router.get('/plAddRole', function (req, res, next) {
    http.get('http://restapi.amap.com/v3/config/district?subdistrict=2&key=d7ef28febfcb3b464420532bd3f12293', function (res) {
        var json = '';
        res.setEncoding('utf-8');
        res.on('data',function(chunk){
            console.log('数据片段分隔-----------------------\r\n');
            console.log(chunk);
            json += chunk;
        });
        res.on('end',function(){
            console.log('响应结束********');
            console.log(json);
            res.json({
                status:'success',
                message:json
            })
        });
    });
});

你可能感兴趣的:(nodejs)