koajs / router

Router middleware for Koa. Maintained by @forwardemail and @ladjs.
MIT License
853 stars 181 forks source link

Map object is empty in the context body #120

Closed valorad closed 1 year ago

valorad commented 3 years ago

node.js version: v14.16.1

npm/yarn and version: 6.14.12

@koa/router version: @10.0.0

koa version: @2.13.1

Code sample:

const map = new Map([
  ["a", "b"],
  ["c", "d"],
])

router.get(`/api`, async (ctx) => {
  ctx.body = map
})

Expected Behavior:

Front-end receives: { "a:" "b", "c": "d" }

Actual Behavior:

Front-end receives: {}

Additional steps, HTTP request details, or to reproduce the behavior or a test case:

Reproduction Repo:

https://codesandbox.io/s/investigation-koa-router-map-gzz6n?file=/src/index.js

yeliex commented 3 years ago

Map is not an acceptable type of koajs

Takes a look at koajs document or code for more information https://koajs.com/#response-body-

3imed-jaberi commented 3 years ago

@valorad, if you need support Map .. you can open an issue here.

3imed-jaberi commented 3 years ago

@niftylettuce, please close this issue