diff options
Diffstat (limited to 'src/server/api/api-handler.ts')
| -rw-r--r-- | src/server/api/api-handler.ts | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/server/api/api-handler.ts b/src/server/api/api-handler.ts index 7fbc200fc0..80a4fd97c8 100644 --- a/src/server/api/api-handler.ts +++ b/src/server/api/api-handler.ts @@ -11,7 +11,7 @@ export default (endpoint: IEndpoint, ctx: Koa.Context) => new Promise((res) => { const reply = (x?: any, y?: ApiError) => { if (x == null) { ctx.status = 204; - } else if (typeof x === 'number') { + } else if (typeof x === 'number' && y) { ctx.status = x; ctx.body = { error: { @@ -23,7 +23,8 @@ export default (endpoint: IEndpoint, ctx: Koa.Context) => new Promise((res) => { } }; } else { - ctx.body = x; + // 文字列を返す場合は、JSON.stringify通さないとJSONと認識されない + ctx.body = typeof x === 'string' ? JSON.stringify(x) : x; } res(); }; |