Skip to content

Commit

Permalink
Remove res.jsonp(status, obj) signature
Browse files Browse the repository at this point in the history
closes #2940
  • Loading branch information
tunniclm authored and dougwilson committed Jan 28, 2017
1 parent 25fdefa commit ab1c9e9
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 25 deletions.
1 change: 1 addition & 0 deletions History.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This incorporates all changes after 4.13.1 up to 4.14.0.

* remove:
- `res.json(status, obj)` signature - use `res.status(status).json(obj)`
- `res.jsonp(status, obj)` signature - use `res.status(status).jsonp(obj)`
- `res.vary()` (no arguments) -- provide a field name as an argument

5.0.0-alpha.2 / 2015-07-06
Expand Down
11 changes: 1 addition & 10 deletions lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,20 +230,11 @@ res.json = function json(obj) {
*/

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];
}

// settings
var app = this.app;
var replacer = app.get('json replacer');
var spaces = app.get('json spaces');
var body = stringify(val, replacer, spaces);
var body = stringify(obj, replacer, spaces);
var callback = this.req.query[app.get('jsonp callback name')];

// content-type
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

0 comments on commit ab1c9e9

Please sign in to comment.