Rev 7209 | Rev 7212 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
import React, { useEffect } from 'react'
import { axios } from '../../utils'
import { useLocation } from 'react-router-dom'
import { addNotification } from '../../redux/notification/notification.actions'
import { useDispatch } from 'react-redux'
const MyCoachViewPage = () => {
const dispatch = useDispatch()
const { pathname } = useLocation()
const getQuestion = () => {
axios
.get(pathname, {
headers: {
'Content-Type': 'application/json',
},
})
.then((response) => {
const { data, success } = response.data
if (!success) {
const errorMessage =
typeof data === 'string'
? data
: 'Error interno. Por favor, inténtelo de nuevo más tarde.'
dispatch(addNotification({ style: 'danger', msg: errorMessage }))
return
}
console.log(data)
})
.catch((error) => {
dispatch(
addNotification({
style: 'danger',
msg: 'Error interno. Por favor, inténtelo de nuevo más tarde.',
})
)
throw new Error(error)
})
}
useEffect(() => {
getQuestion()
}, [])
return <div>MyCoachViewPage</div>
}
export default MyCoachViewPage