environments.tsx 772 B

12345678910111213141516171819202122232425262728
  1. import EnvironmentActions from 'sentry/actions/environmentActions';
  2. import {Client} from 'sentry/api';
  3. /**
  4. * Fetches all environments for an organization
  5. *
  6. * @param organizationSlug The organization slug
  7. */
  8. export async function fetchOrganizationEnvironments(
  9. api: Client,
  10. organizationSlug: string
  11. ) {
  12. EnvironmentActions.fetchEnvironments();
  13. try {
  14. const environments = await api.requestPromise(
  15. `/organizations/${organizationSlug}/environments/`
  16. );
  17. if (!environments) {
  18. EnvironmentActions.fetchEnvironmentsError(
  19. new Error('retrieved environments is falsey')
  20. );
  21. return;
  22. }
  23. EnvironmentActions.fetchEnvironmentsSuccess(environments);
  24. } catch (err) {
  25. EnvironmentActions.fetchEnvironmentsError(err);
  26. }
  27. }