fix(SW-664): Fixed issue with params when fetching data from API in relation to Hotellisting
This commit is contained in:
@@ -273,10 +273,10 @@ export async function getHotelIdsByCityId(
|
||||
) {
|
||||
return unstable_cache(
|
||||
async function (params: URLSearchParams) {
|
||||
getHotelIdsCounter.add(1, { cityId })
|
||||
getHotelIdsCounter.add(1, { params: params.toString() })
|
||||
console.info(
|
||||
"api.hotel.hotel-ids start",
|
||||
JSON.stringify({ query: { cityId } })
|
||||
JSON.stringify({ params: params.toString() })
|
||||
)
|
||||
const apiResponse = await api.get(
|
||||
api.endpoints.v1.Hotel.hotels,
|
||||
@@ -287,14 +287,14 @@ export async function getHotelIdsByCityId(
|
||||
if (!apiResponse.ok) {
|
||||
const responseMessage = await apiResponse.text()
|
||||
getHotelIdsFailCounter.add(1, {
|
||||
cityId,
|
||||
params: params.toString(),
|
||||
error_type: "http_error",
|
||||
error: responseMessage,
|
||||
})
|
||||
console.error(
|
||||
"api.hotel.hotel-ids fetch error",
|
||||
JSON.stringify({
|
||||
query: { cityId },
|
||||
params: params.toString(),
|
||||
error: {
|
||||
status: apiResponse.status,
|
||||
statusText: apiResponse.statusText,
|
||||
@@ -310,14 +310,14 @@ export async function getHotelIdsByCityId(
|
||||
const validatedHotelIds = getHotelIdsByCityIdSchema.safeParse(apiJson)
|
||||
if (!validatedHotelIds.success) {
|
||||
getHotelIdsFailCounter.add(1, {
|
||||
cityId,
|
||||
params: params.toString(),
|
||||
error_type: "validation_error",
|
||||
error: JSON.stringify(validatedHotelIds.error),
|
||||
})
|
||||
console.error(
|
||||
"api.hotel.hotel-ids validation error",
|
||||
JSON.stringify({
|
||||
query: { cityId },
|
||||
params: params.toString(),
|
||||
error: validatedHotelIds.error,
|
||||
})
|
||||
)
|
||||
@@ -327,12 +327,12 @@ export async function getHotelIdsByCityId(
|
||||
getHotelIdsSuccessCounter.add(1, { cityId })
|
||||
console.info(
|
||||
"api.hotel.hotel-ids success",
|
||||
JSON.stringify({ query: { cityId } })
|
||||
JSON.stringify({ params: params.toString() })
|
||||
)
|
||||
|
||||
return validatedHotelIds.data
|
||||
},
|
||||
[`hotels`, params.toString()],
|
||||
[`hotelsByCityId`, params.toString()],
|
||||
{ revalidate: TWENTYFOUR_HOURS }
|
||||
)(params)
|
||||
}
|
||||
@@ -403,7 +403,7 @@ export async function getHotelIdsByCountry(
|
||||
|
||||
return validatedHotelIds.data
|
||||
},
|
||||
[`hotels`, params.toString()],
|
||||
[`hotelsByCountry`, params.toString()],
|
||||
{ revalidate: TWENTYFOUR_HOURS }
|
||||
)(params)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user