Skip to content

Commit 2f70cec

Browse files
committed
part 15
1 parent ccb9661 commit 2f70cec

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/api/story.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const HN_BASE_URL = 'http://hn.algolia.com/api/v1/search?query=';
2+
3+
const fetchStories = (query) =>
4+
fetch(HN_BASE_URL + query)
5+
.then(response => response.json());
6+
7+
export {
8+
fetchStories,
9+
};

src/components/SearchStories.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@ import React, { Component } from 'react';
22
import { observable, action } from 'mobx';
33
import { observer, inject } from 'mobx-react';
44
import Button from './Button';
5-
6-
const HN_BASE_URL = 'http://hn.algolia.com/api/v1/search?query=';
7-
8-
const fetchStories = (query) =>
9-
fetch(HN_BASE_URL + query)
10-
.then(response => response.json());
5+
import { fetchStories } from '../api/story';
116

127
@inject('storyStore') @observer
138
class SearchStories extends Component {

0 commit comments

Comments
 (0)