Download wp-calypso/client/data/geo/use-geolocation-query.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 498 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/data/geo/use-geolocation-query.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/data/geo/use-geolocation-query.ts
-
curl -L -o use-geolocation-query.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/data/geo/use-geolocation-query.ts
498 Bytes
| import { useQuery } from '@tanstack/react-query'; | |
| export interface GeoLocationData { | |
| city: string; | |
| country_long: string; | |
| country_short: string; | |
| latitude: string; | |
| longitude: string; | |
| region: string; | |
| } | |
| export const useGeoLocationQuery = ( options = {} ) => | |
| useQuery< GeoLocationData >( { | |
| queryKey: [ 'geo' ], | |
| queryFn: () => | |
| fetch( 'https://public-api.wordpress.com/geo/' ).then( ( response ) => response.json() ), | |
| staleTime: Infinity, | |
| meta: { persist: false }, | |
| ...options, | |
| } ); | |