Rejecting promises
See original GitHub issueHow do you reject promises inside the then handlers?
Restangular.all('resource').get().then(function(){
//how to reject it?
}, function(){
//how to reject it?
});
Do you just construct the rejection using $q service? I thought there might be something inside Restangular I would be using.
$q.reject();
Issue Analytics
- State:
- Created 10 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Promise.reject() - JavaScript - MDN Web Docs
The Promise.reject() method returns a Promise object that is rejected with a given reason.
Read more >JavaScript promise reject() Method - GeeksforGeeks
The Promise.reject() method is used to return a rejected Promise object with a given reason for rejection. It is used for debugging purposes ......
Read more >JavaScript Promises - reject vs. throw - Stack Overflow
If it returns a rejected promise, the promise returned by the call to then is resolved to that promise (and will ultimately be...
Read more >JavaScript Promise Tutorial – How to Resolve or Reject ...
A Promise executor should call only one resolve or one reject . Once one state is changed (pending => fulfilled or pending =>...
Read more >Reject a Promise in JavaScript - Mastering JS
The Promise.reject() function is the most concise way to create a rejected promise that contains a given error. You should then use .catch() ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Below is an example of returning the rejection from the then success handler. I personally prefer to use the catch handler to handle the errors.
It just means that catch is not final and you chain them in the way you like.