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