Javascript 获取API中的消息属性';s捕捉函数

Javascript 获取API中的消息属性';s捕捉函数,javascript,promise,Javascript,Promise,请允许我问一个可能很简单的问题。有人能告诉我fetchAPI末尾catch函数中参数err的message属性来自哪里吗?例如,在下面的代码片段中 fetch('exmaple.json') .then(response => response.json()) .then(json => randomlyMadeFunction()) .catch(err => console.log('Fetch problem: ' + err.message)); 我知道f

请允许我问一个可能很简单的问题。有人能告诉我
fetch
API末尾catch函数中参数
err
message
属性来自哪里吗?例如,在下面的代码片段中

fetch('exmaple.json')
  .then(response => response.json())
  .then(json => randomlyMadeFunction())
  .catch(err => console.log('Fetch problem: ' + err.message));
我知道fetch返回一个
Promise
,最后
catch
函数将拒绝原因作为参数,在本例中为
err
。我搜索了许多文章,但我无法找出
err
message
属性的来源。任何解释或暗示都将不胜感激


提前感谢。

如果在
获取期间发生错误,则
异常
类型错误
将传递给
捕获
回调,请参阅:

  • abortorror
    由于调用了
    AbortController
    方法
    abort()
    方法,请求被中止
  • TypeError
    指定的URL字符串包括用户凭据。应使用
    授权提供此信息
    标题
Error
s,因此具有
message
属性,请参阅。

console.log(JSON.Stringify(err))。您可以在控制台中看到所有键及其值