getting user in app
This commit is contained in:
parent
90fd2905fb
commit
28b8578605
6 changed files with 62 additions and 25 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { useState } from 'react'
|
||||
import { useEffect, useState } from 'react'
|
||||
import reactLogo from '../assets/react.svg'
|
||||
import viteLogo from '/vite.svg'
|
||||
import './App.css'
|
||||
|
|
@ -8,15 +8,28 @@ import { or } from '../utils/types'
|
|||
|
||||
function App() {
|
||||
const [count, setCount] = useState(0)
|
||||
const [loading, setLoading] = useState(false)
|
||||
const userAPI = useUserAPI();
|
||||
const useAuth = useAuth0();
|
||||
|
||||
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)
|
||||
})
|
||||
// if (user_id.length > 1) {
|
||||
|
||||
// userAPI.getUser(user_id).then(resp => {
|
||||
// console.log(resp)
|
||||
// })
|
||||
// }
|
||||
useEffect(() => {
|
||||
if (loading) return;
|
||||
setLoading(true)
|
||||
userAPI.getUser(user_id).then(resp => {
|
||||
console.log(resp)
|
||||
}).finally(() => {
|
||||
setLoading(false)
|
||||
})
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<><div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue