Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Gary Ng committed Aug 20, 2018
2 parents 1587341 + 7bb2b88 commit 5fb9fe4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/apis/news.api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export const simpleFetch = (url, onSuccess, onError) => fetch(url)
.then(
successResponse => successResponse.json(),
errorResponse => errorResponse.json()
);

export const UserProfileAPI = {

byId: userId => simpleFetch(`https://hacker-news.firebaseio.com/v0/user/${userId}.json`)

};
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import Search from './components/Search/Search.component';
import NewsListTable from './components/NewsList/NewsListTable';
import CurrentDetails from './components/NewsDetails/CurrentDetails';
import UserProfileContainer from './components/UserProfile/UserProfileContainer';
import { UserProfileAPI } from './apis/news.api';

// Network request example (no redux)
UserProfileAPI.byId('mudil').then(
successResponse => console.log('success:', successResponse),
errorResponse => console.log('error:', errorResponse));

ReactDOM.render(
<Provider store={store}>
Expand Down

0 comments on commit 5fb9fe4

Please sign in to comment.