webpro / dyson

Node server for dynamic, fake JSON.
837 stars 62 forks source link

Sending custom status clears body #93

Closed jasperblues closed 5 years ago

jasperblues commented 5 years ago
module.exports = {
    path: '/api/customers',
    template: {
        data: {
            id: uuid(),
            type: "customer",
            attributes: {
                project: "ZZ",
                network: "ZZ",
                customer_id: uuid(),
                project_group_id: null,
                customer_name: g.name(),
                is_active: "Y",
                currency: "USD",
                ar_customer_id: null,
                payer_name: null,
                payer_email: null,
                fein: null,
                external_customer_id: null
            }
        }
    },
    status: (req, res, next) => {
        res.status(HttpStatus.CREATED);
        next(); 
    }
};

Expected:

Body is returned.

Actual:

Empty body.

webpro commented 5 years ago

That's weird. Probably I'll have some time to look into this in the coming days.

webpro commented 5 years ago

What I suspect is going on, is that you're getting a cached response. GET responses are cached by default. So please try to either set cache: false or use a different endpoint path.

webpro commented 5 years ago

Also see https://github.com/webpro/dyson/blob/master/test/config.js#L149-L163

webpro commented 5 years ago

Closing due to inactivity.