Very details article about promises: https://web.dev/promises/
.then(CALL_BACK_FUNCTION(VARIABLE){…}) and ,catch(CALL_BACK_FUNCTION(VARIABLE){…})fulfilled or rejected, so the .then(…) can actually take up to 2 call-back functions, the first one for fulfill, and the second one for rejection call-back. Like: fetch("https://api.example.com/items")
.then(res => res.json())
.then(
(result) => {
this.setState({
isLoaded: true,
items: result.items
});
},
(error) => {
this.setState({
isLoaded: true,
error: error
});
}
)
then(undefined, CALL_BACK_FUNCTION(VARIABLE){…})