如何在函数外返回响应?

编程入门 行业动态 更新时间:2024-10-04 01:26:35

如何在<a href=https://www.elefans.com/category/jswz/34/1771370.html style=函数外返回响应?"/>

如何在函数外返回响应?

我正在尝试返回正文作为响应。该值正确地显示在

console.log(result);
中,但在我尝试
return result
主体时不起作用,但它没有返回任何内容。这是我的代码

const getPhotosData = async (photosUrl,cks) => {
    const curl = new Curl()
    const urld = photosUrl
    curl.setOpt(Curl.option.URL, urld)
    curl.setOpt(Curl.option.SSL_VERIFYPEER, 0)
    curl.setOpt(Curl.option.COOKIEFILE, 'cookies/'+cks)
    curl.setOpt(Curl.option.FOLLOWLOCATION, true)
    curl.on('end', function(statusCode, body, headers) {
       const result = body;
       
        // var bodii = console.info(this.getInfo(Curl.info.TOTAL_TIME));        
        this.close(); 
        console.log(result);
        return result;
    });   
    curl.perform();       
}
回答如下:

更多推荐

如何在函数外返回响应?

本文发布于:2024-05-31 06:07:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1771353.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:函数   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!