Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(useStrapi): add optional query params to create / update in v5 #426

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/runtime/composables-v5/useStrapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@
*
* @param {string} contentType - Content type's name pluralized
* @param {Record<string, any>} data - Form data
* @param {Strapi5RequestParams} [params] - Query parameters
* @returns Promise<T>
*/
const create = <T>(contentType: string, data: Partial<T>): Promise<Strapi5ResponseSingle<T>> => {
return client(`/${contentType}`, { method: 'POST', body: { data } })
const create = <T>(contentType: string, data: Partial<T>, params: Strapi5RequestParams = {}): Promise<Strapi5ResponseSingle<T>> => {
return client(`/${contentType}`, { method: 'POST', body: { data }, params })
}

/**
Expand All @@ -61,9 +62,10 @@
* @param {string} contentType - Content type's name pluralized
* @param {string} documentId - ID of entry to be updated
* @param {Record<string, any>} data - Form data
* @param {Strapi5RequestParams} [params] - Query parameters
* @returns Promise<T>
*/
const update = <T>(contentType: string, documentId: string | Partial<T>, data?: Partial<T>): Promise<Strapi5ResponseSingle<T>> => {
const update = <T>(contentType: string, documentId: string | Partial<T>, data?: Partial<T>, params: Strapi5RequestParams = {}): Promise<Strapi5ResponseSingle<T>> => {

Check failure on line 68 in src/runtime/composables-v5/useStrapi.ts

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 18)

'params' is assigned a value but never used. Allowed unused args must match /^_/u

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

U probably wanted to assign the params to the client. In that case u'd fix pipelines.
return client(path, { method: 'PUT', body: { data }, params })

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ty. Idk how i missed that lol

if (typeof documentId === 'object') {
data = documentId
documentId = undefined
Expand Down
Loading