mirror of
https://github.com/Nezumi-2711/onedrive-vercel-index.git
synced 2026-09-22 13:38:45 +00:00
rename useAxiosFetch hook for universal fetch usage
This commit is contained in:
@@ -2,19 +2,19 @@ import axios from 'axios'
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
// Custom hook to fetch raw file content on mount
|
||||
export default function useFileContent(odRawUrl: string): { content: string; error: string; validating: boolean } {
|
||||
export default function useAxiosGet(fetchUrl: string): { content: string; error: string; validating: boolean } {
|
||||
const [content, setContent] = useState('')
|
||||
const [validating, setValidating] = useState(true)
|
||||
const [error, setError] = useState('')
|
||||
|
||||
useEffect(() => {
|
||||
axios
|
||||
.get(odRawUrl)
|
||||
.get(fetchUrl)
|
||||
.then(res => setContent(res.data))
|
||||
.catch(e => setError(e.message))
|
||||
.finally(() => {
|
||||
setValidating(false)
|
||||
})
|
||||
}, [odRawUrl])
|
||||
}, [fetchUrl])
|
||||
return { content, error, validating }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user