如何在post命令时获取错误内容?

在模拟post中,如果内容有错误,返回的信息里含有错误说明:


目前的代码是:

得到的返回结果是:

只有400
以下是代码内容,希望大佬们多多指点。

try {
            const res = await context.http.post(`${this._pineconeBaseUtl}/query`, data, { headers: {
                "Api-Key": this._pineconeKey,
                "Content-Type": 'application/json'
            } });
        return res.matches.map(match => match.metadata);
            }
        catch(e)
        {
            this._logger.info(e)
        }
2 个赞

e 里面是有更多内容的。使用 e.response.data 获取你想要的错误信息。

2 个赞