3
Is the following
I am new to javascript and I am not able to handle this error. I am trying to call a function and putting a .catch()
to avoid error UnhandledPromiseRejectionWarning soon after it, but would like to make a check of 'if an error occurs, do so'.
I tried to do this check using a if()
, but my console stops due to Syntaxerror: Unexpected token if. I’ve tried to use try...catch
, but error occurred UnhandledPromiseRejectionWarning that I spoke... My code resembles this:
//um pouco de código aqui
function(args).catch(error => console.log(error),
if(error){
//Código que deve ser executado caso ocorra erro
});
//um pouco mais de código aqui
In short, it is possible to put a if()
within a .catch()
? Is there a better way to make this check?
Thanks a lot, Sergio! You got me out of a jam =D
– Lost Woods