JSFiddle - React, Tailwind, and code Playground

JavaScript

let retText = "", obj = {};

let getIt = () => {
  console.log('getIt begins')
  let fetcher = fetch('/', {})
    .then(response => response.text())
    .then(text => {
    	console.log('getIt\'s last then')
    	retText = text
    })
  console.log('getIt finishes')
  return fetcher
}

obj.start = () => {
	console.log('start begins')
  getIt();
  // retText should be the HTML of the document, so lets show the length.
  console.log('length of retText: ' + retText.length)
  // It's 0, because the fetch hasn't finished.
	console.log('start finishes')
  return obj;
}
obj.middle = () => {
	console.log('middle called')
  return obj;
}
obj.end = () => {
	console.log('end called')
  return obj;
}

obj.start().middle().end();