You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import type { FetchOptions } from 'ofetch';
// ...
find: <T>(contentType: string, params?: Strapi4RequestParams, fetchOptions?: FetchOptions) => Promise<T>;
I guess typescript issue would be fixed if I would use const { find } = useStrapi4() but since Strapi v4 is the default I assume that useStrapi() should follow useStrapi4() type structure by default.
all the best,
Nenad
The text was updated successfully, but these errors were encountered:
Sparo
changed the title
Missing "fetchOptions" type declaration on find method on useStrapi composable
Missing "fetchOptions" type declaration on find method in useStrapi composable
May 29, 2024
Version
@nuxtjs/strapi: v1.12.0
nuxt: v3.11.2
Steps to reproduce
I am using
find
method per docs: https://strapi.nuxtjs.org/usage#findHere we have documented 3 arguments where 3rd is
fetchOptions
(https://github.com/unjs/ofetch/blob/main/src/types.ts#L34)based on that - I want to pass
query
object intofetchOptions
so I can do some customization on the Strapi V4 side. Here is the code:Everything is working fine but typescript is reporting following error:
Error: Expected 1-2 arguments, but got 3 .ts(2554)
What is Expected?
I expect typescript linter not to report invalid number of arguments.
What is actually happening?
What I have checked is that in the source code on line: https://github.com/nuxt-modules/strapi/blob/dev/src/runtime/composables-v4/useStrapi.ts#L5 are defined just two arguments
find<F = T>(contentType: string, params?: Strapi4RequestParams): Promise<Strapi4ResponseMany<F>>
but in the actual code of the find method there are 3 of them: https://github.com/nuxt-modules/strapi/blob/dev/src/runtime/composables-v4/useStrapi4.ts#L22I assume that on the line https://github.com/nuxt-modules/strapi/blob/dev/src/runtime/composables-v4/useStrapi.ts#L5 is missing type declaration something like this:
I guess typescript issue would be fixed if I would use
const { find } = useStrapi4()
but since Strapi v4 is the default I assume thatuseStrapi()
should followuseStrapi4()
type structure by default.all the best,
Nenad
The text was updated successfully, but these errors were encountered: