How to output the results of request.post in Node.JS to the browser? Using res.write () will report an error!

the following is a request code. I need to send the cleartext information to the browser.
I know that using res.write () can be output to the browser. But what should I do if I report an error?

request.post({url:ajaxurlip + url, form: {"req":ciphertext}}, function(error,response,body){
            if (!error && response.statusCode == 200) {
                var resp = JSON.parse(body);
                if(resp.status == 0) {
                    var cleartext = CryptoJS.AES.decrypt(
                        resp.body,
                        CryptoJS.enc.Utf8.parse(myAES), {
                            iv: "",
                            mode: CryptoJS.mode.ECB
                        }
                       );
                       //  cleartext 
                       cleartext = JSON.parse(CryptoJS.enc.Utf8.stringify(cleartext));
                       
                       
                       res.write(cleartext)  //
                       
                }
            }
        })
Mar.03,2021

res.write (cleartext) replace with res.send (cleartext) try

Menu