Download wp-calypso/client/data/followers/use-follower-query.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 798 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/data/followers/use-follower-query.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/data/followers/use-follower-query.js
-
curl -L -o use-follower-query.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/data/followers/use-follower-query.js
798 Bytes
| import { useQuery } from '@tanstack/react-query'; | |
| import wpcom from 'calypso/lib/wp'; | |
| const useFollowerQuery = ( siteId, subscriberId, type ) => { | |
| /** | |
| * Normalizes a follower object. Changes 'avatar' to 'avatar_URL' allowing a follower | |
| * object to be used with the Gravatar component. | |
| * @see normalizeFollower in client/data/followers/use-followers-query.js | |
| */ | |
| function normalizeFollower( follower ) { | |
| return { | |
| avatar_URL: follower.avatar, | |
| ...follower, | |
| }; | |
| } | |
| return useQuery( { | |
| queryKey: [ 'subscriber', siteId, subscriberId, type ], | |
| queryFn: () => | |
| wpcom.req.get( { | |
| path: `/sites/${ siteId }/followers/${ subscriberId }?type=${ type }&http_envelope=1`, | |
| apiNamespace: 'rest/v1.1', | |
| } ), | |
| select: normalizeFollower, | |
| } ); | |
| }; | |
| export default useFollowerQuery; | |