I am trying to access the fortnite API using node.js. I have everything setup as specified in the documentation, but am getting these few errors:
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.
The code I have so far is:
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);
});
});
This is my first time messing around with node.js on my own, so I have really no idea what is going on with these errors. I had attempted to google the errors but all the explanations either went way over my head or looked like they were written in a different language.
EDIT: For anyone viewing this later, my error was caused by having 2FA (2 factor authentication) enabled on my account. You are going to have to disable that completely. Also, will later find out that Fiddler 4 won't work after starting the game to get your Fortnite API key. I found some after hours of googling so I will leave them here:
CLIENT LAUNCHER TOKEN: MzRhMDJjZjhmNDQxNGUyOWIxNTkyMTg3NmRhMzZmOWE6ZGFhZmJjY2M3Mzc3NDUwMzlkZmZlNTNkOTRmYzc2Y2Y=
FORTNITE CLIENT TOKEN: ZWM2ODRiOGM2ODdmNDc5ZmFkZWEzY2IyYWQ4M2Y1YzY6ZTFmMzFjMjExZjI4NDEzMTg2MjYyZDM3YTEzZmM4NGQ=
(be sure to include the "=")