I have a simple service.js that looks like this:
import axios from 'axios'
import { useContext } from 'react'
import APIContext from '../context/api/context'
function GetApi() {
const { API } = useContext(APIContext)
console.log(API)
return API
}
const api = axios.create({
baseURL: `${GetApi()}`,
})
export default api
Whenever I try to use the API, it throws me an error saying:
Invalid Hook Call. Hooks can only be called inside the body of a function component