Skip to content
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
7 changes: 7 additions & 0 deletions .changeset/fix-async-router-controller.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"strapi-plugin-webtools": patch
---

Fix async handling in router controller

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.
2 changes: 1 addition & 1 deletion packages/core/server/controllers/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default {

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