I have read many different ways of adding timeouts within a promise, but most, if not all, seem to utilise the setTimeout()
method. By definition:
The setTimeout() method calls a function or evaluates an expression after a specified number of milliseconds.
What I am looking for is a way to say:
"If the function executed inside the promise (that will either resolve or
reject the promise), does not complete within a specified x number of
milliseconds, automatically reject or raise an exception."
If this is the same as the defined above (using the setTimeout()
method), an explanation would be highly appreciated!