Skip to content

Commit e59a1f7

Browse files
committed
fix(singleType): This currenly pluralises all names even for single types which returns 404
1 parent c92c0f1 commit e59a1f7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/strapi-client/src/client/client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export class StrapiClient {
7171
* @param entityName - The singular name of the entity you want to query/write
7272
* @param id - The ID of the entity you want to query/write, or undefined
7373
* @param params - The params to pass to the Strapi API
74+
* @param isSingleType - Whether the entity is a single type
7475
* @returns The endpoint URL
7576
*/
7677
public getEndpoint(
@@ -81,7 +82,8 @@ export class StrapiClient {
8182
): string {
8283
const contentType = this.entityMap.get(entityName);
8384
const query = qs.stringify(params, { addQueryPrefix: true, encodeValuesOnly: true });
84-
return this.getUrl(`${contentType?.path}${id ? `/${id}` : ''}${query}`);
85+
const path = isSingleType ? contentType?.singularName : pluralize(contentType?.singularName);
86+
return this.getUrl(`/api/${path}${id ? `/${id}` : ''}${query}`);
8587
}
8688

8789
/**

0 commit comments

Comments
 (0)