DEV Community

Discussion on: JavaScript: Concept of Promise

Collapse
 
kanogithub profile image
Wei

Is there a way to get states? Such as pending...?

Collapse
 
swarnaliroy94 profile image
Swarnali Roy • Edited

Pending state starts while generating the promise, until it is either resolved or rejected. That means, until you get any result, successful or failure, the state is pending.
Well, if you working with React or React Native, in that case you can set the initial state as pending state, set resolve in then section and set reject in catch section. I'll write about it later in another post clearly.

Collapse
 
moriseif1 profile image
moriseif1

You can use defualt state with pending string and then after resolve you can change state with resolve and in catch section set state with reject !
If you mean state in React 😂

Collapse
 
swarnaliroy94 profile image
Swarnali Roy

Correct