System Information
- Strapi Version: 4.5.6
- Operating System: MacOS Catalina
- Database: SQLite
- Node Version: 16.18.1
- NPM Version: 8.19.2
- Yarn Version: 1.22.19
Issue
As of Strapi v4.5.6 (and possibly prior releases), Strapi logs the following warning:
Deprecation warning: Usage of "axiosInstance" utility is deprecated and will be removed in the next major release. Instead, use the useFetchClient() hook, which is exported from the admin: { useFetchClient } from "@strapi/helper-plugin"
When attempting to use the new hook in Admin development, I consistently receive the following error:
Uncaught TypeError: (0 , _strapi_helper_plugin__WEBPACK_IMPORTED_MODULE_2__.useFetchClient) is not a function
Implementation
Based on what I can infer from the source code (https://github.com/strapi/strapi/blob/main/packages/core/helper-plugin/lib/src/hooks/useFetchClient/index.js), useFetchClient
is essentially just a wrapper for an axios instance, however the following code returns the aforementioned error:
import { useFetchClient } from '@strapi/helper-plugin'
const Component = () => {
const client = useFetchClient()
const handleGetData = async () => {
const response = await client.get('/posts')
console.log(response)
}
return (
<button onClick={handleGetData}>Test</button>
)
}
I must assume I am simply using the hook incorrectly, however it us curious to me that even just invoking the hook (i.e. without implementing the handleGetData
function) throws the same error.
Any help in this matter would be appreciated, as documentation on helper-plugin functions is currently nonexistent.
Thanks!