for example, this API of WeChat Mini Programs: https://developers.weixin.qq....
returns binary data. If successful, the binary content is a picture. If it fails, the binary content is json text
now it is time to use fs.createWriteStream
to download the content to a file and then read this file to determine whether it has failed. Can you get the binary content directly instead of downloading the binary content to the file?
const writeStream = fs.createWriteStream("./a")
request({
method: "post",
url: `https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=${accessToken}`,
body: JSON.stringify({})
}).pipe(writeStream)
writeStream.on("finish", function () {
//
})