import { IPostResponse , IPostResult } from '../types/post-page' ; import { HTTP , buildURL , NETWORK_BAN_MESSAGE } from '../utils' ; example export const getMediaByPostId = async ( postId ) : Promise < IPostResult > => { const result = { post : null , } ; const url = buildURL ( `p/${ postId }/` ) ; const response = await HTTP < IPostResponse > ( url ) ; const content = response ?. entry_data ?. PostPage ; if ( content ) { const { shortcode_media = null } = { ... content ?. [ 0 ] ?. graphql } ; result . post = shortcode_media ; } else { throw new Error ( NETWORK_BAN_MESSAGE ) ; } return result ; } ; export default getMediaByPostId ;