Skip to content

Question about request.accepts() function #340

@BolverBlitz

Description

@BolverBlitz

Did the syntax change or is it a bug?

I´ve used request.accepts() in the past to respond to the clients wishes, ive updated hyperexpress from a about 2 year old version to the latest and this code now throws an error.
I looked through commits, my code works with 6.17.2 and breaks 6.17.3
There are 2 commits 8f9975d and 939293e where the this part was modifyed. @RatchetS2

TypeError: Cannot read private member #negotiator from an object whose class did not declare it
    at Request.accepts (C:\Users\1515\Documents\GitHub\italy-healfcare\node_modules\hyper-express\src\components\compatibility\ExpressRequest.js:43:28)
    at Request.accepts (C:\Users\1515\Documents\GitHub\italy-healfcare\node_modules\hyper-express\src\components\http\Request.js:950:29)
    at Route.handler (C:\Users\1515\Documents\GitHub\italy-healfcare\testing.js:6:33)
    at Route.handle (C:\Users\1515\Documents\GitHub\italy-healfcare\node_modules\hyper-express\src\components\router\Route.js:136:35)
    at Server._handle_uws_request (C:\Users\1515\Documents\GitHub\italy-healfcare\node_modules\hyper-express\src\components\Server.js:527:19)
    at C:\Users\1515\Documents\GitHub\italy-healfcare\node_modules\hyper-express\src\components\Server.js:421:26

Example Code:

const hyperExpress = require('hyper-express');

const app = new hyperExpress.Server();

app.get('/', (request, response) => {
    const acceptsHtml = request.accepts('html');
    response.send(`Accepts HTML: ${acceptsHtml}`);
});

app.listen(3000, () => {
    console.log('Server listening on port 3000');
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions