<commit_before>import fetch from 'isomorphic-fetch'

const _getRequest = url =>
      fetch(url).then((response) => {
        if (response.ok) {
          return response.json()
        } throw Error(response.statusText)
      })

const _postJSONRequest = (url, data) =>
      fetch(url, {
        method: 'post',
        headers: {
          Accept: 'application/json',
          'Content-Type': 'application/json',
        },
        body: JSON.stringify(data),
      })
  .then((response) => {
    if (response.ok) {
      return response.json()
    } throw Error(response.statusText)
  })

const addFeed = url => _postJSONRequest('/feeds/', { url })

const refreshFeedList = () =>
      _getRequest('/feeds/')
      .then(response => response["_embedded"]["feeds"])

const refreshFeed = feedId =>
      _postJSONRequest(`/feeds/${feedId}`)
      .then(response => response["_embedded"]["entries"])

const fetchFeedEntries = feedId =>
      _getRequest(`/feeds/${feedId}/entries`)
      .then(response => response["_embedded"]["entries"])<commit_msg>Handle case where response is empty<commit_after>import fetch from 'isomorphic-fetch'

const _getRequest = url =>
      fetch(url).then((response) => {
        if (response.ok) {
          if (response.status == 200) {
            return response.json()
          } else {
            return []
          }
        } throw Error(response.statusText)
      })

const _postJSONRequest = (url, data) =>
      fetch(url, {
        method: 'post',
        headers: {
          Accept: 'application/json',
          'Content-Type': 'application/json',
        },
        body: JSON.stringify(data),
      })
      .then((response) => {
        if (response.ok) {
          if (response.status == 200) {
            return response.json()
          } else {
            return []
          }
        } throw Error(response.statusText)
      })

const addFeed = url => _postJSONRequest('/feeds/', { url })

const refreshFeedList = () =>
      _getRequest('/feeds/')
      .then((response) => {
        if (("_embedded") in response) {
          return response["_embedded"]["feeds"]
        } else {
          return []
        }
      })

const refreshFeed = feedId =>
      _postJSONRequest(`/feeds/${feedId}`)
      .then((response) => {
        if (("_embedded") in response) {
          return response["_embedded"]["entries"]
        } else {
          return []
        }
      })

const fetchFeedEntries = feedId =>
      _getRequest(`/feeds/${feedId}/entries`)
      .then((response) => {
        if (("_embedded") in response) {
          return response["_embedded"]["entries"]
        } else {
          return []
        }
      })
{'fraction_non_alphanumeric': 0.15619189289698773, 'fraction_numerical': 0.002231312755671253, 'mean_word_length': 2.0568181818181817, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 0, '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': '1037453', 'n_tokens_mistral': 779, 'n_tokens_neox': 779, 'n_words': 149}