import 'whatwg-fetch';

const apiBaseURL = 'http://localhost:1337';

export const bookshelfApi = {
  getBooks() {
    return fetch(`${apiBaseURL}/books`)
      .then(response => response.json())
      .catch(error =>
        console.error(
          'Something went awry trying to fetch books from bookshelf-server.',
          error
        )
      );
  }
};

import 'whatwg-fetch';

const apiBaseURL = 'http://localhost:1337';

function parseJSONFromResponse(response) {
  return response.json();
}

export const bookshelfApi = {
  getBooks() {
    return fetch(`${apiBaseURL}/books`)
      .then(parseJSONFromResponse)
      .catch(error =>
        console.error(
`Something went wrong trying to fetch books from bookshelf-server.
Make sure the bookshelf-server is started.`, error));
  }
};

Refactor services to use a function with a clear name instead of arrow function for parsing the response to JSON.
Refactor services to use a function with a clear name instead of arrow function for parsing the response to JSON.
