Skip to content

Commit 25fdefa

Browse files
tunniclmdougwilson
authored andcommitted
Remove res.json(status, obj) signature
closes #2939
1 parent a856456 commit 25fdefa

File tree

3 files changed

+2
-25
lines changed

3 files changed

+2
-25
lines changed

History.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
This incorporates all changes after 4.13.1 up to 4.14.0.
55

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

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

lib/response.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -203,20 +203,11 @@ res.send = function send(body) {
203203
*/
204204

205205
res.json = function json(obj) {
206-
var val = obj;
207-
208-
// support res.json(status, obj)
209-
if (arguments.length === 2) {
210-
deprecate('res.json(status, obj): Use res.status(status).json(obj) instead');
211-
this.statusCode = arguments[0];
212-
val = arguments[1];
213-
}
214-
215206
// settings
216207
var app = this.app;
217208
var replacer = app.get('json replacer');
218209
var spaces = app.get('json spaces');
219-
var body = stringify(val, replacer, spaces);
210+
var body = stringify(obj, replacer, spaces);
220211

221212
// content-type
222213
if (!this.get('Content-Type')) {

test/res.json.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -145,19 +145,4 @@ describe('res', function(){
145145
})
146146
})
147147
})
148-
149-
describe('.json(status, object)', function(){
150-
it('should respond with json and set the .statusCode', function(done){
151-
var app = express();
152-
153-
app.use(function(req, res){
154-
res.json(201, { id: 1 });
155-
});
156-
157-
request(app)
158-
.get('/')
159-
.expect('Content-Type', 'application/json; charset=utf-8')
160-
.expect(201, '{"id":1}', done)
161-
})
162-
})
163148
})

0 commit comments

Comments
 (0)