Skip to content
This repository was archived by the owner on Sep 1, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)`
Expand Down
33 changes: 15 additions & 18 deletions src/lib/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<object[]> {
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<object> {
return this.request('get', `/${contentTypePluralized}/${id}`);
public getEntry(contentType: string, id: string): Promise<object> {
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<object> {
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<object> {
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<object> {
return this.request('delete', `/${contentTypePluralized}/${id}`);
public deleteEntry(contentType: string, id: string): Promise<object> {
return this.request('delete', `/${contentType}/${id}`);
}

/**
Expand Down