{"action":"opened","issue":{"url":"https://api.github.com/repos/jdeferred/jdeferred/issues/56","labels_url":"https://api.github.com/repos/jdeferred/jdeferred/issues/56/labels{/name}","comments_url":"https://api.github.com/repos/jdeferred/jdeferred/issues/56/comments","events_url":"https://api.github.com/repos/jdeferred/jdeferred/issues/56/events","html_url":"https://github.com/jdeferred/jdeferred/issues/56","id":73201048,"number":56,"title":"How to chain several promises?","user":{"login":"sandro-csimas","id":1282074,"avatar_url":"https://avatars.githubusercontent.com/u/1282074?v=3","gravatar_id":"","url":"https://api.github.com/users/sandro-csimas","html_url":"https://github.com/sandro-csimas","followers_url":"https://api.github.com/users/sandro-csimas/followers","following_url":"https://api.github.com/users/sandro-csimas/following{/other_user}","gists_url":"https://api.github.com/users/sandro-csimas/gists{/gist_id}","starred_url":"https://api.github.com/users/sandro-csimas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sandro-csimas/subscriptions","organizations_url":"https://api.github.com/users/sandro-csimas/orgs","repos_url":"https://api.github.com/users/sandro-csimas/repos","events_url":"https://api.github.com/users/sandro-csimas/events{/privacy}","received_events_url":"https://api.github.com/users/sandro-csimas/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-05-05T04:06:48Z","updated_at":"2015-05-05T04:06:48Z","closed_at":null,"body":"Using javascript promise libraries like \"bluebird\" i can return another promise inside \"then\" and call \"then\" again with the result of the last promise.\r\n````\r\nSocialAccount.forge({user_id: user.id, network: network}).fetch({require: true}).then(function(socialAccount) {\r\n  return socialAccount.save({show_link: show === true ? 1 : 0}, {patch: true});\r\n}).then(function(socialAccount) {\r\n  resolve(socialAccount);\r\n}).catch(NotFoundError, function(err) {\r\n  reject(messages.notFoundError('user.showNetwork.userNotConnected', 'The user is not connected to this network', err));\r\n}).catch(function(err) {\r\n  reject(messages.unexpectedError('user.showNetwork.error', 'Error setting network to show user link.', err));\r\n});\r\n````"}}