-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from arifszn/rename-devto
Rename dev from dev.to
- Loading branch information
Showing
4 changed files
with
45 additions
and
45 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 |
---|---|---|
@@ -1,42 +1,42 @@ | ||
const { request, formatMediumPost, formatDevtoPost } = require("./util"); | ||
const { request, formatMediumPost, formatDevPost } = require('./util'); | ||
|
||
module.exports = { | ||
/** | ||
* Get most recent medium posts | ||
* | ||
* @param {Object} param | ||
* @returns {Array} posts | ||
*/ | ||
getMediumPost: async ({ | ||
user | ||
}) => { | ||
try { | ||
if (!user) return []; | ||
/** | ||
* Get most recent medium posts | ||
* | ||
* @param {Object} param | ||
* @returns {Array} posts | ||
*/ | ||
getMediumPost: async ({ user }) => { | ||
try { | ||
if (!user) return []; | ||
|
||
let response = await request(`https://api.rss2json.com/v1/api.json?rss_url=https://medium.com/feed/@${user}`); | ||
let response = await request( | ||
`https://api.rss2json.com/v1/api.json?rss_url=https://medium.com/feed/@${user}` | ||
); | ||
|
||
return response.data.items.map(item => formatMediumPost(item)); | ||
} catch (error) { | ||
return []; | ||
} | ||
}, | ||
/** | ||
* Get most recent dev.to posts | ||
* | ||
* @param {Object} param | ||
* @returns {Array} posts | ||
*/ | ||
getDevtoPost: async ({ | ||
user | ||
}) => { | ||
try { | ||
if (!user) return []; | ||
let response = await request(`https://dev.to/api/articles?per_page=10&username=${user}`); | ||
return response.data.items.map((item) => formatMediumPost(item)); | ||
} catch (error) { | ||
return []; | ||
} | ||
}, | ||
/** | ||
* Get most recent dev posts | ||
* | ||
* @param {Object} param | ||
* @returns {Array} posts | ||
*/ | ||
getDevPost: async ({ user }) => { | ||
try { | ||
if (!user) return []; | ||
|
||
let response = await request( | ||
`https://dev.to/api/articles?per_page=10&username=${user}` | ||
); | ||
|
||
return response.data.map(item => formatDevtoPost(item)); | ||
} catch (error) { | ||
return []; | ||
} | ||
return response.data.map((item) => formatDevPost(item)); | ||
} catch (error) { | ||
return []; | ||
} | ||
} | ||
}, | ||
}; |
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