-
Notifications
You must be signed in to change notification settings - Fork 86
Description
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#find
Here 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 into fetchOptions
so I can do some customization on the Strapi V4 side. Here is the code:
const { find } = useStrapi()
const response = await find<BlogItem>('articles', { filters: { slug } }, {
query: {
customQueryParam: 'something'
}
})
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#L22
I 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:
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