当 Stripe oAuth 过程失败时,Stripe API 将返回一个 JSON 字典(无论是什么)。我已将其存储为变量,但我无法访问它“error_description”中的值。这是相关 Stripe 文档的链接
不确定它是否有区别,但这是在服务器端方法的 Meteor 应用程序中。
我将以下内容存储为一个名为“错误”的变量。这是我在 console.log(error); 时得到的。
{ [Error: failed [400] { "error": "invalid_grant", "error_description": "Authorization code does not exist: ac_7z4pnJ8ee71yJNxguV6wiINIf10fgl6j" }] stack: [Getter] }
我的问题是:如何访问“error_description”?
写的时候好像不行
var newError = error.error_description
如果有人可以帮助我获得很棒的error_description,谢谢!
更新 添加 .message 删除了部分响应,但我仍然无法 JSON.parse 它或访问 error_description
var error = error.message 导致
failed [400] { "error": "invalid_grant", "error_description": "Authorization code does not exist: ac_7z4pnJ8ee71yJNxguV6wiINIf10fgl6j" }