JSFiddle - React, Tailwind, and code Playground

JavaScript

var params = {
  a: 1,
  b: 2
};

var data = new FormData();
data.append("json", JSON.stringify(params));

var currentRequest = new Request("/echo/json/", {
  method: "POST",
  body: data
});

var start, complete;
var fetchStart = new Promise(function(_start) {
  start = _start;
})

var fetchComplete = new Promise(function(_complete) {
  complete = _complete;
});

fetchStart.then(function(startData) {
  console.log(startData)
});

fetchComplete.then(function(completeData) {
  console.log(completeData)
});

var request = fetch(currentRequest);

[request, start({
    "fetchStarted": currentRequest
 })].shift()
  .then(function(res) {
    if (res.ok) {
      complete({
        "fetchCompleted": res
      })
    };
    return res.json();
  })
  .then(function(data) {
    document.body.textContent = JSON.stringify(data)
  })
  .catch(function(err) {
     complete({
        "fetchCompleted": res,
        "error": err
      })
  })