Skip to content

Commit

Permalink
chore: scaffolded useMapServerQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikSin committed Nov 28, 2022
1 parent 9920abc commit 5dc5b81
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/renderer/hooks/useMapServerQuery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import ky from 'ky/umd'
import { useQuery } from '@tanstack/react-query'

// local host
// global port number

const MAP_SERVER_URL = 'http://127.0.0.1:' + window.mapServerPort

/**
* @param {'/styles' | `/styles/${string}` | '/tiles' | `/tiles/${string}`} resourcePath URL path to resource on Map Server (needs to start with `/`)
*/
export default function useMapServerQuery (resourcePath) {
return useQuery({
queryKey: [resourcePath],
queryFn: () => ky.get(MAP_SERVER_URL + resourcePath)
})
}

0 comments on commit 5dc5b81

Please sign in to comment.