Skip to content

Commit 821ae6c

Browse files
authored
Merge pull request #320 from cayblood/fix/await-transform-response
Fix async handling in router controller
2 parents 324ec80 + 49f7086 commit 821ae6c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"strapi-plugin-webtools": patch
3+
---
4+
5+
Fix async handling in router controller
6+
7+
Add await keyword before transformResponse call to properly handle the Promise returned by the method. This resolves the issue where the router endpoint returns empty objects instead of the expected content.

packages/core/server/controllers/core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default {
3535

3636
// Format response.
3737
const sanitizedEntity = await sanitizeOutput(responseEntity, contentTypeObj, auth);
38-
ctx.body = strapi.controller(contentType as UID.Controller)
38+
ctx.body = await strapi.controller(contentType as UID.Controller)
3939
// @ts-expect-error
4040
// The strapi object is typed in a way that the following is expected to be a controller.
4141
// In fact that is not true, as this also exposes the helper functions of the controller.

0 commit comments

Comments
 (0)