我正在尝试使用 node.js 访问堡垒之夜 API。我已经按照文档中的说明进行了所有设置,但是出现了以下几个错误:
Fortnite-API - Credentials Params OK
(node:3036) UnhandledPromiseRejectionWarning: #<Object>
(node:3036) UnhandledPromiseRejectionWarning: Unhandled promise
rejection. This error originated either by throwing inside of an async
function without a catch block, or by rejecting a promise which was not
handled with .catch(). (rejection id: 1)
(node:3036) [DEP0018] DeprecationWarning: Unhandled promise rejections
are deprecated. In the future, promise rejections that are not handled
will terminate the Node.js process with a non-zero exit code.
我到目前为止的代码是:
const Fortnite = require("fortnite-api");
let fortniteAPI = new Fortnite(
[
"redacted",
"redacted",
"redacted",
"redacted"
],
{
debug: true
}
);
fortniteAPI.login().then(() => {
fortniteAPI
.checkPlayer("x got", "pc")
.then(stats => {
console.log(stats);
})
.catch(err => {
console.log(err);
});
});
这是我第一次独自处理 node.js,所以我真的不知道这些错误是怎么回事。我曾试图用谷歌搜索错误,但所有的解释要么让我无法理解,要么看起来像是用不同的语言编写的。
编辑:对于稍后查看此内容的任何人,我的错误是由于在我的帐户上启用了 2FA(2 因素身份验证)引起的。你将不得不完全禁用它。此外,稍后会发现在启动游戏以获取您的 Fortnite API 密钥后 Fiddler 4 将无法工作。经过数小时的谷歌搜索,我找到了一些,所以我将它们留在这里:
客户端启动令牌:MzRhMDJjZjhmNDQxNGUyOWIxNTkyMTg3NmRhMzZmOWE6ZGFhZmJjY2M3Mzc3NDUwMzlkZmZlNTNkOTRmYzc2Y2Y=
FORTNITE 客户端代币:ZWM2ODRiOGM2ODdmNDc5ZmFkZWEzY2IyYWQ4M2Y1YzY6ZTFmMzFjMjExZjI4NDEzMTg2MjYyZDM3YTEzZmM4NGQ=
(一定要包括“=”)
你能不能像下面那样在登录承诺中加入一个陷阱。看看你是否能够捕捉到错误。
fortniteAPI.login().then(() => {
fortniteAPI
.checkPlayer("x got", "pc")
.then(stats => {
console.log(stats);
})
.catch(err => {
console.log(err);
});
}).catch((error)=>{console.log('error at login-->',error)});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句