【发布时间】:2016-06-10 17:39:58
【问题描述】:
当 Stripe oAuth 过程失败时,Stripe API 将返回一个 JSON 字典(无论是什么)。我已将其存储为变量,但我无法访问它“error_description”中的值。 Here is a link to the relevant Stripe docs
不确定是否会有所不同,但这是在 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" }
【问题讨论】:
标签: javascript json meteor stripe-connect