检查响应是流还是json

时间:2017-06-20 12:24:19

标签: node.js request

如何使用请求模块检查来自http post请求的响应是json格式还是流?

request({
            uri: proxy_url,
            method: req.route.method,
            body: req.params.file
        }, (err, resp, body) => {
            if (err)
                console.log(err)

            if (body == Stream)
                //write to file
            else {
                console.log(body)
            }
        })

0 个答案:

没有答案