diff --git a/README.md b/README.md index 1ed4772..6e3e51a 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ await strapi.authenticateProvider('facebook'); ``` You can now fetch private APIs ```js -const posts = await strapi.getEntries('post'); +const posts = await strapi.getEntries('posts'); ``` ### Files management @@ -83,11 +83,11 @@ const files = await strapi.upload(form, { ### `authenticateProvider(provider, params)` ### `setToken(token, comesFromStorage)` ### `clearToken(token)` -### `getEntries(contentType, params)` -### `getEntry(contentType, id)` -### `createEntry(contentType, data)` -### `updateEntry(contentType, id, data)` -### `deleteEntry(contentType, id)` +### `getEntries(contentTypePluralized, params)` +### `getEntry(contentTypePluralized, id)` +### `createEntry(contentTypePluralized, data)` +### `updateEntry(contentTypePluralized, id, data)` +### `deleteEntry(contentTypePluralized, id)` ### `searchFiles(query)` ### `getFiles(params)` ### `getFile(id)` diff --git a/src/lib/sdk.ts b/src/lib/sdk.ts index afe8df5..8c30eda 100644 --- a/src/lib/sdk.ts +++ b/src/lib/sdk.ts @@ -225,64 +225,67 @@ export default class Strapi { /** * List entries - * @param contentType + * @param contentTypePluralized * @param params Filter and order queries. */ public getEntries( - contentType: string, + contentTypePluralized: string, params?: AxiosRequestConfig['params'] ): Promise { - return this.request('get', `/${contentType}`, { + return this.request('get', `/${contentTypePluralized}`, { params }); } /** * Get a specific entry - * @param contentType Type of entry + * @param contentTypePluralized Type of entry pluralized * @param id ID of entry */ - public getEntry(contentType: string, id: string): Promise { - return this.request('get', `/${contentType}/${id}`); + public getEntry(contentTypePluralized: string, id: string): Promise { + return this.request('get', `/${contentTypePluralized}/${id}`); } /** * Create data - * @param contentType Type of entry + * @param contentTypePluralized Type of entry pluralized * @param data New entry */ public createEntry( - contentType: string, + contentTypePluralized: string, data: AxiosRequestConfig['data'] ): Promise { - return this.request('post', `/${contentType}`, { + return this.request('post', `/${contentTypePluralized}`, { data }); } /** * Update data - * @param contentType Type of entry + * @param contentTypePluralized Type of entry pluralized * @param id ID of entry * @param data */ public updateEntry( - contentType: string, + contentTypePluralized: string, id: string, data: AxiosRequestConfig['data'] ): Promise { - return this.request('put', `/${contentType}/${id}`, { + return this.request('put', `/${contentTypePluralized}/${id}`, { data }); } /** * Delete an entry - * @param contentType Type of entry + * @param contentTypePluralized Type of entry pluralized * @param id ID of entry */ - public deleteEntry(contentType: string, id: string): Promise { - return this.request('delete', `/${contentType}/${id}`); + public deleteEntry( + contentTypePluralized: string, + id: string + ): Promise { + return this.request('delete', `/${contentTypePluralized}/${id}`); } /**