-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LMS-42 fetch latest articles from Landgriffon Medium account
- Loading branch information
1 parent
364f8b3
commit 4bb4cf4
Showing
3 changed files
with
108 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import axios from 'axios'; | ||
import { useQuery } from 'react-query'; | ||
|
||
type PostItem = { | ||
title: string; | ||
pubDate: string; | ||
link: string; | ||
guid: string; | ||
thumbnail: string; | ||
description: string; | ||
content: string; | ||
categories: string[]; | ||
}; | ||
|
||
type PostsResponse = { | ||
status: string; | ||
feed: { | ||
url: string; | ||
title: string; | ||
link: string; | ||
author: string; | ||
description: string; | ||
image: string; | ||
}; | ||
items: PostItem[]; | ||
}; | ||
|
||
function usePosts() { | ||
const getPosts = async () => { | ||
const { data } = await axios.get<PostsResponse>( | ||
'https://api.rss2json.com/v1/api.json?rss_url=https://medium.com/feed/@landgriffon', | ||
); | ||
return data; | ||
}; | ||
|
||
return useQuery('posts', getPosts); | ||
} | ||
|
||
export default usePosts; |