Advertisement
Guest User

Untitled

a guest
Feb 1st, 2015
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. var API = {
  2. get: function() {
  3. return new Promise(function() {
  4. // ... some code to get remotely
  5. });
  6. }
  7. }
  8.  
  9. var UserAPI = {
  10. getById: function(id) {
  11. return API.get('/users/' + id);
  12. }
  13. }
  14.  
  15. var UserActionCreators = {
  16. requestUserById: function(userId) {
  17. UserAPI.getById(userId)
  18. .then(function(data) {
  19. UserServerActionCreators.handleUserSuccess(data);
  20. })
  21. .catch(function() {
  22. // Notify of error
  23. UserServerActionCreators.handleUserError(data);
  24. });
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement