useAxios()

useAxios() simplifies API calls in a React component. It uses underlying Axios client, which is preconfigured to work with MagicJS making it easier to interact with web services.

Here's an example:

import { useAxios } from "@magicjs.dev/frontend"

const client = useAxios()

React.useEffect(() => {
  client.get("https://testApi.com").then((res) => {
    console.log(res)
  })
}, [])

Click here to refer GitHub.

Last updated