api/elt: add query timeout (1 minute)
This commit is contained in:
parent
85a9fdd44e
commit
5549c1305f
@ -1,5 +1,6 @@
|
||||
import type * as ELT from './types';
|
||||
import getUrls from '@/config/urls';
|
||||
import { TIMEOUT } from '@/constants/request';
|
||||
import { withHandleError } from '@/utils/axios';
|
||||
import type { QueryFunctionContext } from '@tanstack/react-query';
|
||||
import axios from 'axios';
|
||||
@ -8,12 +9,16 @@ const { URL_ELT_KASKO, URL_ELT_OSAGO } = getUrls();
|
||||
|
||||
export async function getEltOsago(payload: ELT.RequestEltOsago, { signal }: QueryFunctionContext) {
|
||||
return withHandleError(
|
||||
axios.post<ELT.ResponseEltOsago>(URL_ELT_OSAGO, payload, { signal }).then(({ data }) => data)
|
||||
axios
|
||||
.post<ELT.ResponseEltOsago>(URL_ELT_OSAGO, payload, { signal, timeout: TIMEOUT })
|
||||
.then(({ data }) => data)
|
||||
);
|
||||
}
|
||||
|
||||
export async function getEltKasko(payload: ELT.RequestEltKasko, { signal }: QueryFunctionContext) {
|
||||
return withHandleError(
|
||||
axios.post<ELT.ResponseEltKasko>(URL_ELT_KASKO, payload, { signal }).then(({ data }) => data)
|
||||
axios
|
||||
.post<ELT.ResponseEltKasko>(URL_ELT_KASKO, payload, { signal, timeout: TIMEOUT })
|
||||
.then(({ data }) => data)
|
||||
);
|
||||
}
|
||||
|
||||
@ -8,3 +8,9 @@ export const STALE_TIME = dayjs
|
||||
hours: 1,
|
||||
})
|
||||
.asMilliseconds();
|
||||
|
||||
export const TIMEOUT = dayjs
|
||||
.duration({
|
||||
minutes: 1,
|
||||
})
|
||||
.asMilliseconds();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user