Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var API = {
- get: function() {
- return new Promise(function() {
- // ... some code to get remotely
- });
- }
- }
- var UserAPI = {
- getById: function(id) {
- return API.get('/users/' + id);
- }
- }
- var UserActionCreators = {
- requestUserById: function(userId) {
- UserAPI.getById(userId)
- .then(function(data) {
- UserServerActionCreators.handleUserSuccess(data);
- })
- .catch(function() {
- // Notify of error
- UserServerActionCreators.handleUserError(data);
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement