从网络选项卡中看到错误消息,但不在 try/catch console.log(错误)中

Seeing error message from network tab, but not in the try/catch console.log(error)

我在做一个项目的前端部分,后端是做的,基本上当一个条件满足时,后端会发送409冲突和特定的错误信息,我的工作就是捕获那个错误信息并让它显示在前端。

但是我无法在try-catch块中获取错误消息,并且只能在Chrome的网络选项卡中看到错误消息。

这是我的 try-catch 前端代码

try{
            const response = await this.request({
                path: `/api/xxx/xxx/{xxx}/xx`.replace(`{${"xxx"}}`, xx(String(requestParameters.terminalId))),
                method: 'PUT',
                headers: headerParameters,
                query: queryParameters,
                body: UpdateTerminalDataPortRequestDtoToJSON(requestParameters.updateTerminalDataPortRequestDto),
            }, initOverrides);
        }
        catch(e){
            console.log("error message")
            console.error(e)
        }

这是网络选项卡

控制台日志错误如下所示:

如何获得与网络中显示的相同的错误消息?

提前致谢....如有任何意见,我们将不胜感激

通过 catch

访问 err.response 解决了这个问题
.catch(function (err) {
    console.log(err.response)
})