Ask coding questions

← Back to all posts
Detect if promise has been rejected in JS
ruiwenge2 (1135)

How do I detect if a JavaScript promise has been rejected?

@Coder100 because you’re good with js and most of my questions have been answered by you
Answered by Coder100 (18903) [earned 5 cycles]
View Answer
Comments
hotnewtop
Coder100 (18903)
promise.then(... good ...).catch(... rejected! ...)

a rejection is basically an error

ruiwenge2 (1135)

@Coder100 alright thanks I didn’t know that lol

ruiwenge2 (1135)

@Coder100 and here are 5 cycles for you…