Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 2200 Rev 2201
Línea 43... Línea 43...
43
      }
43
      }
44
    )
44
    )
Línea 45... Línea 45...
45
 
45
 
46
    this.#client.interceptors.response.use(
46
    this.#client.interceptors.response.use(
47
      async (response) => {
47
      async (response) => {
Línea 48... Línea 48...
48
        const { fatal, success, data } = response.data
48
        const { fatal } = response.data
49
 
-
 
50
        if (fatal === true) {
-
 
51
          window.localStorage.removeItem('jwt')
-
 
52
          window.localStorage.removeItem('aes')
49
 
53
          window.location.reload()
-
 
54
          return { success: false, data: 'La sesión ha caducado' }
-
 
55
        }
-
 
56
 
-
 
57
        if (success === false) {
-
 
58
          const errorType = typeof data
-
 
59
 
-
 
60
          if (errorType !== 'string') throw new Error(data)
-
 
61
 
-
 
62
          const errorsArray = []
-
 
63
 
-
 
64
          for (const key in data) {
-
 
65
            data[key].forEach((error) => {
-
 
66
              errorsArray.push(`${key} ${error}`)
-
 
67
            })
-
 
68
          }
-
 
69
 
50
        if (fatal === true) {
Línea 70... Línea 51...
70
          return { ...response, data: errorsArray }
51
          throw new Error('La sesión ha caducado')
71
        }
52
        }
72
 
53