1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-16 22:50:10 +03:00

F OpenNebula/one#5422: Add request timeout

This commit is contained in:
Sergio Betanzos 2021-07-05 14:36:41 +02:00
parent f10df39d15
commit 6251097cf3
No known key found for this signature in database
GPG Key ID: E3E704F097737136

View File

@ -4,16 +4,18 @@ import { httpCodes } from 'server/utils/constants'
import { messageTerminal } from 'server/utils/general'
import { findStorageData, isDevelopment } from 'client/utils'
import { JWT_NAME, APP_URL } from 'client/constants'
import { T, JWT_NAME, APP_URL } from 'client/constants'
const http = axios.create({ baseURL: APP_URL })
http.interceptors.request.use((config) => {
http.interceptors.request.use(config => {
const token = findStorageData(JWT_NAME)
token && (config.headers.Authorization = `Bearer ${token}`)
return {
...config,
timeout: 45_000,
timeoutErrorMessage: T.Timeout,
withCredentials: true,
validateStatus: status =>
Object.values(httpCodes).some(({ id }) => id === status)
@ -40,10 +42,7 @@ http.interceptors.response.use(
return Promise.reject(response)
},
error => {
console.log('error interceptor', error)
return error
}
error => error
)
export const RestClient = {