Open damianobarbati opened 4 years ago
The following results in a payload hola and not the json "hola".
hola
"hola"
import http from 'http'; import koa from 'koa'; import json from 'koa-json'; const app = new koa(); app.use(json()); app.use(ctx => ctx.body = 'hola'); http.createServer(app.callback()).listen(1234);
Current workaround:
app.use(async (ctx, next) => { await next(); if (typeof ctx.body === 'string') ctx.body = `"${ctx.body}"`; });
why would you send a string JSON-encoded?
@jonathanong for consistency:
The following results in a payload
hola
and not the json"hola"
.Current workaround: