Closed victormachado-ada-tech closed 2 months ago
I want to be able to submit a POST request with a File array in the body. Currently the client only supports a single File.
I can do what I want by passing a FormData to the body, but it's not much convenient because I lose type safety.
Here is an example of code of what I would like to happen:
const c = initContract(); const contract = c.router({ uploadWithArray: { method: "POST", path: "/upload", body: c.type<{ files: File[] }>(), responses: { 200: c.type<{ totalFileSize: number }>(), }, }, }); const client = initClient(contract, { baseUrl: "http://localhost:3333", baseHeaders: {}, }); async function makeUpload() { const response = await client.uploadWithArray({ body: { files: [new File([""], "file1.txt"), new File([""], "file2.txt")], }, }); return response; }
I want to be able to submit a POST request with a File array in the body. Currently the client only supports a single File.
I can do what I want by passing a FormData to the body, but it's not much convenient because I lose type safety.
Here is an example of code of what I would like to happen: