Created
March 8, 2018 22:36
-
-
Save jonathanmv/6436c3f5cde980851acc2e78e0f725fb to your computer and use it in GitHub Desktop.
Getting JSON data from Medium url
This file contains hidden or 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
| const textInPostId = async (username, postId) => { | |
| const url = userPostJsonUrl(username, postId) | |
| const data = await getJsonData(url) | |
| return textInPostFromResponse(data) | |
| } | |
| const textInPostFromResponse = (response, types = DEFAULT_TYPES) => { | |
| const paragraphs = _.get(response, 'payload.value.content.bodyModel.paragraphs', []) | |
| const filtered = paragraphs.filter(({ type }) => types.includes(type)) | |
| return filtered.map(({text}) => text) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment