Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 2213 | Rev 2221 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 2213 Rev 2219
Línea 1... Línea 1...
1
import { useState, useEffect } from 'react'
1
import { useState, useEffect } from 'react'
2
import { useDispatch } from 'react-redux'
2
import { useDispatch } from 'react-redux'
Línea 3... Línea 3...
3
 
3
 
4
import { axios } from '@app/utils'
4
import { axios } from '@app/utils'
-
 
5
import { addNotification } from '@app/redux/notification/notification.actions'
Línea 5... Línea 6...
5
import { addNotification } from '@app/redux/notification/notification.actions'
6
import { logout } from '@app/redux/auth/auth.actions'
6
 
7
 
7
const useFetch = (url, defaultValue = {}) => {
8
const useFetch = (url, defaultValue = {}) => {
8
  const [data, setData] = useState(defaultValue)
9
  const [data, setData] = useState(defaultValue)
Línea 38... Línea 39...
38
      .then((data) => setData(data))
39
      .then((data) => setData(data))
39
      .catch((error) => {
40
      .catch((error) => {
40
        dispatch(addNotification({ style: 'danger', msg: error.message }))
41
        dispatch(addNotification({ style: 'danger', msg: error.message }))
Línea 41... Línea 42...
41
 
42
 
42
        if (error.message.includes('sesión')) {
-
 
43
          window.localStorage.removeItem('jwt')
43
        if (error.message.includes('sesión')) {
44
          window.localStorage.removeItem('aes')
44
          dispatch(logout())
45
        }
45
        }
46
      })
46
      })
47
      .finally(() => setIsLoading(false))
47
      .finally(() => setIsLoading(false))