Nest .then() results

by Chad Drummond

JavaScript

var root = 'https://jsonplaceholder.typicode.com';

$.get(root + '/posts').then(function(postsResult) {

	console.log({ postsResult })

	return $.get(root + '/comments').then(function(commentsResult) {
  	console.log({ commentsResult })
    // Whatever we return here is going to be `thenResult`
    return commentsResult
  })

}).then(function(thenResult) {
	console.log({ thenResult })
})