use-http
use-http copied to clipboard
Query params on get request
Is there a way for me to pass query params to a get() function, i.e like axios.get(url, options)?
you should be able to do get('?my=query¶ms=cool')
hey u can build ur url in a useMemo hook and then pass to useFetch hook
const url = useMemo(() => buildUrl(url, {params}) ,[params]) const { get } = useFetch(url, options)
get() // ur get method will be built each time the url changes
also read https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams
Should be fine to do it that way too.
const url = useMemo(() => buildUrl(url, {params}) ,[params])
const { data, loading } = useFetch(url, [])