nodeJS使用request访问图片url的返回数据类型?
发布于 7 年前 作者 hanguiying 7398 次浏览 来自 问答

nodeJS使用request访问图片url的返回数据类型?

const rp = require(‘request-promise’);

await rp({

        method: ‘GET’,

        uri: http://xxxxxxxxxxxxxxxxxxxx/getCaptcha.png,

        jar: true,

        resolveWithFullResponse: true,

        headers: {

            Accept: ‘image/webp,image/apng,image/*,*/*;q=0.8’,

            ‘Connection’: ‘keep-alive’,

            ‘Content-Type’: ‘image/jpeg;charset=UTF-8’,

            ‘User-Agent’: userAgent

        }

}).then(function (res) {

        console.log(res);//返回的 res.data的数据是什么? 图片的字节流吗???

}).catch(function (err) {

        console.log(‘验证码获取失败’, err);

});

回到顶部