function getCsrfToken() {
  var promise = new Promise(function (resolve, reject) {
    var i = 0;
    var waitingOnCSRF = setInterval(function () {
      var metaTag = document.querySelector("meta[name='csrf-token']");
      i++;
      if (metaTag) {
        clearInterval(waitingOnCSRF);
        var authToken = metaTag.getAttribute("content");
        return resolve(authToken);
      } else if (i === 1000) {
        clearInterval(waitingOnCSRF);
        Honeybadger.notify("Could not locate CSRF metatag " + JSON.stringify(localStorage.current_user));
        return reject("Could not locate CSRF meta tag on the page.");
      }
    }, 5);
  });
  return promise;
}
