Hapi: Destructured Tooltip methods

Created on 8 May 2019  ·  2Comments  ·  Source: hapijs/hapi

Are you sure this is an issue with the hapi core module or are you just looking for some help?

Yes. I've just created PR #3949 .

Is this a security related issue?

No.

What are you trying to achieve or the steps to reproduce?

To use destructured response method from h in route handler.

server.route({
  method: 'POST',
  path: '/',
  handler: (req, { response }) => {
    return response({
      message: 'Created',
    }).code(201);
  },
});

What was the result you received?

Debug: internal, implementation, error
    TypeError: Cannot read property 'request' of undefined
    at response (. . . ./node_modules/@hapi/hapi/lib/toolkit.js:177:43)

What did you expect?

Use response without h;

Context

  • node version: v12.2.0
  • hapi version: v18.3.1
non issue

Most helpful comment

The toolkit is a class with prototype methods. You can't deconstruct it. Allowing you to means creating new functions on every toolkit generation instead of reusing the prototype methods. Not going to happen.

All 2 comments

The toolkit is a class with prototype methods. You can't deconstruct it. Allowing you to means creating new functions on every toolkit generation instead of reusing the prototype methods. Not going to happen.

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jeffbski picture jeffbski  ·  5Comments

midknight41 picture midknight41  ·  4Comments

foobar1123 picture foobar1123  ·  3Comments

hueniverse picture hueniverse  ·  4Comments

AdriVanHoudt picture AdriVanHoudt  ·  5Comments