export function checkResponseStatus(response) {
  if (response.status >= 200 && response.status < 300) {
    if (response.statusText === 'No Content' || response.statusText === 'DELETED') {
      return {};
    }
    return response.json();
  } else if (response.status > 100) {
    return response.json().then(data => {
      if (data.data) {
        throw data.data[0];
      } else {
        throw response.statusText;
      }
    });
  }
}
