songhoyun
CDCloudflare Developers
•Created by songhoyun on 5/5/2024 in #workers-help
Issue with FormData Methods in Cloudflare Workers
I cannot directly pass
FormData
as the first parameter to c.newResponse
. The TypeScript error indicates there's no overload that matches this call. The errors are as follows:
1. For the overload (data: Data | null, status?: StatusCode | undefined, headers?: HeaderRecord | undefined): Response
, the error states:
- Argument of type 'FormData' is not assignable to parameter of type 'Data | null'.
- The type 'FormData' is missing several properties required by the type 'ReadableStream<any>', such as 'locked', 'cancel', 'getReader', 'pipeThrough', and three more properties.
2. For the overload (data: Data | null, init?: ResponseInit | undefined): Response
, the same type mismatch issue arises, where 'FormData' is not considered assignable to 'Data | null'.
Here is the NewResponse
interface declaration for clarity:
4 replies
CDCloudflare Developers
•Created by songhoyun on 5/5/2024 in #workers-help
Issue with FormData Methods in Cloudflare Workers
My setup is shown below.
4 replies