From 13a87a640205a6a1ed357b68785803d62f7fa5e5 Mon Sep 17 00:00:00 2001 From: charokn Date: Thu, 23 Oct 2025 17:52:38 +0530 Subject: [PATCH] Added a check in restWrapper to handle undefined values --- packages/drivers/routerlicious-driver/src/restWrapper.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/drivers/routerlicious-driver/src/restWrapper.ts b/packages/drivers/routerlicious-driver/src/restWrapper.ts index d114f29e845f..e9c7d7b9a059 100644 --- a/packages/drivers/routerlicious-driver/src/restWrapper.ts +++ b/packages/drivers/routerlicious-driver/src/restWrapper.ts @@ -47,10 +47,10 @@ const buildRequestUrl = (requestConfig: AxiosRequestConfig) => const axiosBuildRequestInitConfig = (requestConfig: AxiosRequestConfig): RequestInit => { const requestInit: RequestInit = { method: requestConfig.method, - // NOTE: I believe that although the Axios type permits non-string values in the header, here we are - // guaranteed the requestConfig only has string values in its header. - headers: requestConfig.headers as Record, - body: requestConfig.data, + // Only set headers if they exist to avoid passing undefined + ...(requestConfig.headers && { headers: requestConfig.headers as Record }), + // Only set body if it exists to avoid passing undefined + ...(requestConfig.data !== undefined && { body: requestConfig.data }), }; return requestInit; };