Closed SteeledSlagle13 closed 6 years ago
I was getting this error at one point too, unfortunately it was a while ago and I have since fixed/forgotten about them. 2-Auth should definitely be off. Could be the issue. Its not the actual login/credentials though as you get this
Fortnite-API - Credentials Params OK
I think it might be how you're passing info.
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().
I also kept getting that error along w/ the previous. First I'd try throwing a .catch() on the .login() so
fortniteAPI.login().then( function () { console.log('Hello'); }).catch(function(err){ console.log(err); });
Basically it just console logs the error (response/message) if there is one.
If that doesn't help, are you using Express/Router and/or an Ajax function? I feel like my issue was with how I tried to go about an ajax function, I had to place my function on .done() instead of success:
I'll try to look more into it tomorrow, hopefully any of the things I said above were helpful :) gl
I captured both tokens through fiddler and am having the same issue reported by @SteeledSlagle13 . Would really appreciate if you can share any resolutions you may find :)
The error isn't with the info being passed. I tried adding a catch earlier but that didn't change anything other than the unhandled promise rejection.
Code :
fortniteAPI.login().then( function () {
console.log('Hello');
}).catch(function (err) {
console.log(err);
});
Generates :
Fortnite-API - Credentials Params OK
Please enter good token
Well it was a theory but Not the info being passed. How that info is being passed.
BUT wait. Now it generates just "Please enter good token"?
Is the above code all that you're running? (Just to preface) I admit I am by no standards (especially my own) an expert or even "experienced" with git/apis. I still consider myself new to it all.
Looking back at my (horribly notated) commits, seems that I stopped getting the error when I moved my ajax post code from success, to done. Only non cosmetic change I noticed. Any additional code you are running would be helpful, I tried just running the code above, it does nothing but log you in and it does that successfully
If the above is the case, I think its asking in a not so upfront way, what now? You coded it to login, it did. Now it wants to do something so its asking you to send the "good token" aka the username + system (?)
But idk what else your code is doing after you login. But if you no longer get the other error its because you fixed the promise or async function that was being left undone, so to speak.
Additional code would be useful to truly get to the root of the issue.
If that is all you are running try running this
fortniteAPI.login().then(function(){
fortniteAPI.getStatsBR('wrekan', 'pc').then(function(stats){
console.log(stats);
}).catch(function(err){
console.log(err);
});
});
This produces the Params OK log as well as outputs the info requested. I just filled it in with my fortnite info for example.
I tried re-producing your error but right now my code is sitting in a node/express app via router so idk which if not all of that is changing my output. But I can't get the "Please enter good token" to log
Before to declare your express Routing, you need to login on the API to be sure you will get all tokens you need.
I have no idea what was going on with my code.... It works now. ¯_(ツ)_/¯ I feel like this is one of those instances of a meme I saw on reddit a while back 'It doesn't work... Why?' 12 hours later 'It works... Why?'
I literally just added :
fortniteAPI.getStatsBR('wrekan', 'pc').then(function(stats){
console.log(stats);
}).catch(function(err){
console.log(err);
});
into the login. Overall code with out the FortniteApi Object Declaration :
fortniteAPI.login().then(function () {
fortniteAPI.getStatsBR('wrekan', 'pc').then(function (stats) {
console.log(stats);
}).catch(function (err) {
console.log(err+' Inside function error');
});
})
.catch(function (err) {
console.log(err+' Outside function error');
});
I am so happy it is working now :D Thanks everyone I appreciate the help!
Good ! I will close this issue so ;) !
Hello, I know this issue has been resolve like 10 times already... I have looked at the Php repo and the other resolutions.. They all point me to the same Token and Client
I copied both from a previous issue in this repo and I also copied them from the Php repo
When I run my code :
Where **** is replaced with my login information(I have verified it is correct and I have toggle 2 factor Auth on and off).
When running this code I get :
I have no idea what next step to take, so I am looking to anyone who sees this for advice.