-
-
Notifications
You must be signed in to change notification settings - Fork 751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request without Content-Type application/json have empty body #40
Comments
See http://stackoverflow.com/a/17228529/2578205 for solution implementation. |
So technically you could add your own responder using res.format with |
#52 should fix it by allowing to set up the REST provider later. This is the test I added to test it: it('Lets you configure your own middleware before the handler (#40)', function(done) {
var data = { description: 'Do dishes!', id: 'dishes' };
var app = feathers({ rest: false });
app.use(function defaultContentTypeMiddleware (req, res, next) {
req.headers['content-type'] = req.headers['content-type'] || 'application/json';
next();
})
.use(feathers.urlencoded())
.use(feathers.json())
.configure(feathers.rest())
.use('/todo', {
create: function (data, params, callback) {
callback(null, data);
}
});
var server = app.listen(4775);
request({
method: 'POST',
url: 'http://localhost:4775/todo',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data)
}, function (error, response, body) {
assert.deepEqual(JSON.parse(body), data);
server.close(done);
});
}); |
* 'master' of github.com:feathersjs/feathers: release 0.4.0 Updating readme with 0.4.0 changelog. Allow to configure REST handler manually (feathersjs#40) Implementing event filtering and default params for Primus. Extracted common Socket functionality. Documentation for service event dispatching and some cleanup. Adding event dispatching tests for SocketIO. Adding SocketIO handshake data to service call parameters. Initial implementation for SocketIO dispatching mechanism. release 0.3.2 Changelog for 0.3.2 Changing dependencies versions back so that they work with older Node versions. Upgrading dependencies and switching to Lodash. refactor feathers use feathers use other feathers apps
* Update plugin infrastructure to use shx * Fix linting error
* chore(package): update dependencies https://greenkeeper.io/ * docs(readme): add Greenkeeper badge https://greenkeeper.io/ * Update to latest Semistandard
* chore(package): update dependencies https://greenkeeper.io/ * docs(readme): add Greenkeeper badge https://greenkeeper.io/ * Update to latest Semistandard
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue with a link to this issue for related bugs. |
I am using Postman REST Client and neglected to set the
Content-Type
toapplication/json
which resulted in the body not being parsed byexpress.json
and it was passingdata = {}
into my services'create
handler.I suggest that, since JSON is the notation being used for serialization with Feathers, that if the
Content-Type
is blank, it should default toapplication/json
.The text was updated successfully, but these errors were encountered: