From 86c67a58ae172fd1d5374f72216cac38fa0df9b0 Mon Sep 17 00:00:00 2001 From: Jandson Vitorino <101944851+jandsonrj@users.noreply.github.com> Date: Wed, 2 Aug 2023 15:49:50 -0300 Subject: [PATCH] Closed #169 changed default timeout from 5s -> 15s and read_data timeout from 5s -> 2m. Changed the default timeout error message (#175) --- frontend/services/api.js | 5 ++++- frontend/services/product.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/frontend/services/api.js b/frontend/services/api.js index 610c388..10303ae 100644 --- a/frontend/services/api.js +++ b/frontend/services/api.js @@ -10,7 +10,7 @@ import { refreshToken } from './auth' export function getAPIClient(ctx) { const api = axios.create({ // baseURL: '/api', - timeout: 5000, + timeout: 15000, headers: { 'Content-Type': 'application/json', accept: 'application/json' @@ -84,6 +84,9 @@ export function getAPIClient(ctx) { // return Promise.reject(error.response.data) // } } + if (error.code === 'ECONNABORTED' && error.message.includes('timeout')) { + error.message = 'The connection has timed out.' + } return Promise.reject(error) } ) diff --git a/frontend/services/product.js b/frontend/services/product.js index 03ba81c..0e78d40 100644 --- a/frontend/services/product.js +++ b/frontend/services/product.js @@ -143,7 +143,7 @@ export const fetchProductData = ({ queryKey }) => { return } page += 1 - return api.get(`/api/products/${productId}/read_data/`, { params: { page, page_size } }).then(res => res.data) + return api.get(`/api/products/${productId}/read_data/`, { timeout: 120000, params: { page, page_size } }).then(res => res.data) } export const deleteProduct = product_id => {