getting user in callback, set dev audience in env
This commit is contained in:
parent
ac7ee6881a
commit
864b7b0689
2 changed files with 13 additions and 11 deletions
2
.env
2
.env
|
|
@ -2,5 +2,5 @@ VITE_APP_API_URL=https://bxt-dev.api.adaptiveagriculture.ca/v1
|
|||
|
||||
#Auth0
|
||||
VITE_AUTH0_CLIENT_DOMAIN=brandxtech.auth0.com
|
||||
VITE_AUTH0_AUDIENCE=pond.brandxtech.ca
|
||||
VITE_AUTH0_AUDIENCE=bxt-dev.api.adaptiveagriculture.ca
|
||||
VITE_AUTH0_BXT_CLIENT_ID=dzJTpqIeMA4Rwk4xujtwPbAO3TY32bM1
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import { useEffect, useState } from 'react'
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import reactLogo from '../assets/react.svg'
|
||||
import viteLogo from '/vite.svg'
|
||||
import './App.css'
|
||||
|
|
@ -11,25 +11,27 @@ function App() {
|
|||
const [loading, setLoading] = useState(false)
|
||||
const userAPI = useUserAPI();
|
||||
const useAuth = useAuth0();
|
||||
const hasFetched = useRef(false);
|
||||
|
||||
let user_id = or(useAuth.user?.sub, "")
|
||||
// console.log("User ID: ", user_id)
|
||||
|
||||
// if (user_id.length > 1) {
|
||||
|
||||
// userAPI.getUser(user_id).then(resp => {
|
||||
// console.log(resp)
|
||||
// })
|
||||
// }
|
||||
useEffect(() => {
|
||||
if (loading) return;
|
||||
const loadUser = useCallback(() => {
|
||||
// if (loading) return;
|
||||
if (hasFetched.current) return;
|
||||
setLoading(true)
|
||||
console.log("send")
|
||||
userAPI.getUser(user_id).then(resp => {
|
||||
console.log(resp)
|
||||
}).finally(() => {
|
||||
setLoading(false)
|
||||
hasFetched.current = true;
|
||||
})
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (loading) return;
|
||||
loadUser()
|
||||
}, [loading])
|
||||
|
||||
return (
|
||||
<><div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue