diff --git a/src/api/story.js b/src/api/story.js new file mode 100644 index 0000000..4dd9758 --- /dev/null +++ b/src/api/story.js @@ -0,0 +1,9 @@ +const HN_BASE_URL = 'http://hn.algolia.com/api/v1/search?query='; + +const fetchStories = (query) => + fetch(HN_BASE_URL + query) + .then(response => response.json()); + +export { + fetchStories, +}; \ No newline at end of file diff --git a/src/components/SearchStories.js b/src/components/SearchStories.js index 78b7b9a..2f14850 100644 --- a/src/components/SearchStories.js +++ b/src/components/SearchStories.js @@ -2,12 +2,7 @@ import React, { Component } from 'react'; import { observable, action } from 'mobx'; import { observer, inject } from 'mobx-react'; import Button from './Button'; - -const HN_BASE_URL = 'http://hn.algolia.com/api/v1/search?query='; - -const fetchStories = (query) => - fetch(HN_BASE_URL + query) - .then(response => response.json()); +import { fetchStories } from '../api/story'; @inject('storyStore') @observer class SearchStories extends Component {