export function pandaFetch()

in public/js/services/pandaFetch.js [13:39]


export function pandaFetch(url, body) {
  return new Promise(function(resolve, reject) {
    fetch(url, body)
        .then(checkStatus)
        .then(res => resolve(res))
        .catch(err => {
          if (err.status == 419) {
            const store = getStore();
            var reauthUrl = store.getState().config.reauthUrl;

            reEstablishSession(reauthUrl, 5000).then(
                () => {
                  fetch(url, body)
                  .then(checkStatus)
                  .then(res => resolve(res))
                  .catch(err => reject(err));
                },
                error => {
                  throw error;
                });

          } else {
            reject(err);
          }
        });
  });
}