<commit_before>/* @flow */
import type { EventsData } from './types/apiData';

import { mockedEvents } from './mocks/mockedEvents';

function fetchApiEvents(): Promise<EventsData> {
  return new Promise((resolve, reject) => {
    setTimeout(
      () => {
        return resolve(mockedEvents);
      },
      2000
    );
  });
}

export { fetchApiEvents };<commit_msg>fetch data from apiary mock server<commit_after>/* @flow */
import { mockedEvents } from './mocks/mockedEvents';

import type { EventsData } from './types/apiData';

const host = 'https://private-6e9cf6-eventigo.apiary-mock.com/';
const useLocalMock = false;

function fetchApiEvents(): Promise<EventsData> {
  if (useLocalMock) {
    return localMock();
  }

  return fetch(`${host}api/v1/events`).then(response => response.json());
}

const localMock = () => {
  return new Promise((resolve, reject) => {
    setTimeout(
      () => {
        return resolve(mockedEvents);
      },
      1000
    );
  });
};

export { fetchApiEvents };
{'fraction_non_alphanumeric': 0.1610337972166998, 'fraction_numerical': 0.011928429423459244, 'mean_word_length': 3.3034188034188032, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5230389', 'n_tokens_mistral': 318, 'n_tokens_neox': 312, 'n_words': 68}