Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

post status raise exception #76

Closed
Daemoneyes opened this issue Feb 2, 2017 · 2 comments
Closed

post status raise exception #76

Daemoneyes opened this issue Feb 2, 2017 · 2 comments

Comments

@Daemoneyes
Copy link

Using the example code:

module.exports = {
    path: '/feature/:foo?',
    status: function(req, res) {
        if(req.params.foo === '999') {
            res.status(404).send('Feature not found');
        }
    }
}

using a post like this:
http://localhost:3000/feature/123

What i got from terminal is:

TypeError: Object prototype may only be an Object or null: undefined
    at setValues (C:\workspace\xpsmock\node_modules\dyson\lib\response.js:75:22)
    at Object.generate (C:\workspace\xpsmock\node_modules\dyson\lib\response.js:30:27)
    at callbacks (C:\workspace\xpsmock\node_modules\express\lib\router\index.js:164:37)
    at param (C:\workspace\xpsmock\node_modules\express\lib\router\index.js:138:11)
    at param (C:\workspace\xpsmock\node_modules\express\lib\router\index.js:135:11)
    at pass (C:\workspace\xpsmock\node_modules\express\lib\router\index.js:145:5)
    at Router._dispatch (C:\workspace\xpsmock\node_modules\express\lib\router\index.js:173:5)
    at Object.router (C:\workspace\xpsmock\node_modules\express\lib\router\index.js:33:10)
    at next (C:\workspace\xpsmock\node_modules\connect\lib\proto.js:190:15)
    at handleDelegateResponse (C:\workspace\xpsmock\node_modules\cors\lib\index.js:97:9)

The first Post would get correct response, but second would get a 500 internal error. Both Post would get same Error on Node side.

@webpro
Copy link
Owner

webpro commented Feb 7, 2017

Your example seems to works fine, no matter how often I make the request. What version of dyson are you using?

I did find an issue with Express however, this works as intended for the 404 case:

module.exports = {
  path: '/feature/:foo?',
  status: function(req, res) {
    if(req.params.foo === '999') {
      res.sendStatus(404);
    }
  }
}

@webpro
Copy link
Owner

webpro commented Feb 27, 2017

Closing due to inactivity.

@webpro webpro closed this as completed Feb 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants