Closed uykusuz closed 2 months ago
Hi @uykusuz,
Good catch, it's definitely a bug!
Wow awesome, thank you!
-------- Original Message -------- On Apr 13, 2024, 11:48, Taras Batenkov wrote:
Closed #37 as completed.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
Hi,
thank you for your work in this module!
I want to do a post request with a request body. I created a changeset of the problem here.
I add the following line to
playground/app.vue
:await $pets('/store/order', { body: { petId: petId.value }})
That won't compile with the following error:
Argument of type '{ body: { petId: number; }; }' is not assignable to parameter of type 'OpenFetchOptions<"post" | "POST", "post", { post: { requestBody?: { content: { "application/json": { id?: number | undefined; petId?: number | undefined; quantity?: number | undefined; shipDate?: string | undefined; status?: "placed" | ... 2 more ... | undefined; complete?: boolean | undefined; }; "application/xml":...'. Property 'method' is missing in type '{ body: { petId: number; }; }' but required in type '{ method: "post" | "POST"; }'.ts(2345) fetch.ts(14, 77): 'method' is declared here.
When I do what TS wants, i.e. add that
method
parameter with a value of"post"
it doesn't work either. Now it tells me the following:Argument of type '{ method: "post"; body: { petId: number; }; }' is not assignable to parameter of type 'OpenFetchOptions<"post", "post", { post: { requestBody?: { content: { "application/json": { id?: number | undefined; petId?: number | undefined; quantity?: number | undefined; shipDate?: string | undefined; status?: "placed" | ... 2 more ... | undefined; complete?: boolean | undefined; }; "application/xml": { ...; }...'. Type '{ method: "post"; body: { petId: number; }; }' is not assignable to type 'Record<string, never>'.ts(2345)
I tried digging into types, tried google, I cannot find the cause of the problem.
Is this a bug in nuxt-open-fetch or am I doing something wrong?
Thank you in advance for your response!
Regards, Boris