Skip to content

Remove res.jsonp(status, obj) signature #2940

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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

This incorporates all changes after 4.13.1 up to 4.14.0.

* remove:
- `res.jsonp(status, obj)` signature - use `res.status(status).jsonp(val)`

5.0.0-alpha.2 / 2015-07-06
==========================

Expand Down
13 changes: 2 additions & 11 deletions lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,20 +234,11 @@ res.json = function json(obj) {
* res.jsonp(null);
* res.jsonp({ user: 'tj' });
*
* @param {string|number|boolean|object} obj
* @param {string|number|boolean|object} val
* @public
*/

res.jsonp = function jsonp(obj) {
var val = obj;

// support res.jsonp(status, obj)
if (arguments.length === 2) {
deprecate('res.jsonp(status, obj): Use res.status(status).jsonp(obj) instead');
this.statusCode = arguments[0];
val = arguments[1];
}

res.jsonp = function jsonp(val) {
// settings
var app = this.app;
var replacer = app.get('json replacer');
Expand Down
15 changes: 0 additions & 15 deletions test/res.jsonp.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,21 +286,6 @@ describe('res', function(){
})
})

describe('.jsonp(status, object)', function(){
it('should respond with json and set the .statusCode', function(done){
var app = express();

app.use(function(req, res){
res.jsonp(201, { id: 1 });
});

request(app)
.get('/')
.expect('Content-Type', 'application/json; charset=utf-8')
.expect(201, '{"id":1}', done)
})
})

it('should not override previous Content-Types', function(done){
var app = express();

Expand Down