【问题标题】:Getting UnhandledPromiseRejectionWarning: Error: write EPROTO when running my async await function in NodeJS获取 UnhandledPromiseRejectionWarning:错误:在 NodeJS 中运行我的异步等待函数时写入 EPROTO
【发布时间】:2021-11-18 15:23:45
【问题描述】:

直到今天下午我都在运行以下代码,没有任何问题,我没有更改或更新任何内容,不确定是什么原因造成的:

async function getStocks(){

    const { data } = await axios.get('https://gist.githubusercontent.com/graffixnyc/8c363d85e61863ac044097c0d199dbcc/raw/7d79752a9342ac97e4953bce23db0388a39642bf/stocks.json')
    return data // this will be the array of people objects
}

async function abc(){
    let a = await getStocks()
    console.log(a)
}

abc()

它曾经从 JSON 文件中渲染整个数据,但现在抛出以下错误:

(node:1860) UnhandledPromiseRejectionWarning: Error: write EPROTO 14520:error:1408F10B:SSL ` 
routines:ssl3_get_record:wrong version 
number:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:332:`

我不确定哪个依赖项的版本错误,因为我没有更新代码也没有进行任何更改。

【问题讨论】:

    标签: javascript json object async-await axios


    【解决方案1】:

    网站上的数据发送了无效响应,因此问题不在代码中,而在网站数据本身。

    【讨论】:

      【解决方案2】:

      尝试将 Try Catch 添加到您的函数中。

      【讨论】:

      • 我做了,但没有帮助
      • 你是否也在函数调用中添加了try catch?
      • 是的,我得到未定义的答案
      猜你喜欢
      • 1970-01-01
      • 2019-05-02
      • 1970-01-01
      • 2022-07-06
      • 2020-09-23
      • 2018-04-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-11
      相关资源
      最近更新 更多