diff --git a/.nx/version-plans/version-plan-1769591535914.md b/.nx/version-plans/version-plan-1769591535914.md new file mode 100644 index 0000000..c43ff1c --- /dev/null +++ b/.nx/version-plans/version-plan-1769591535914.md @@ -0,0 +1,5 @@ +--- +"@rozenite/network-activity-plugin": patch +--- + +Converted FormData entries iterator to an array before reduce to avoid 'reduce is not a function' and keep request body parsing stable. diff --git a/packages/network-activity-plugin/src/react-native/http/http-utils.ts b/packages/network-activity-plugin/src/react-native/http/http-utils.ts index 7a7c471..c679785 100644 --- a/packages/network-activity-plugin/src/react-native/http/http-utils.ts +++ b/packages/network-activity-plugin/src/react-native/http/http-utils.ts @@ -47,20 +47,19 @@ const getTextPostData = (body: unknown): RequestTextPostData => ({ const getFormDataPostData = (body: FormData): RequestFormDataPostData => ({ type: 'form-data', - value: getFormDataEntries(body).reduce( - (acc, [key, value]) => { - if (isBlob(value)) { - acc[key] = getBinaryPostData(value); - } else if (isArrayBuffer(value)) { - acc[key] = getArrayBufferPostData(value); - } else { - acc[key] = getTextPostData(value); - } + value: Array.from(getFormDataEntries(body)).reduce< + RequestFormDataPostData['value'] + >((acc, [key, value]) => { + if (isBlob(value)) { + acc[key] = getBinaryPostData(value); + } else if (isArrayBuffer(value)) { + acc[key] = getArrayBufferPostData(value); + } else { + acc[key] = getTextPostData(value); + } - return acc; - }, - {}, - ), + return acc; + }, {}), }); export const getRequestBody = (body: XHRPostData): RequestPostData => {