mirror of
https://github.com/typicode/json-server.git
synced 2025-07-31 06:01:50 +08:00
Support x-www-form-urlencoded
This commit is contained in:
@ -15,7 +15,7 @@ module.exports = function (source) {
|
||||
var router = express.Router()
|
||||
|
||||
// Add middlewares
|
||||
router.use(bodyParser.json({limit: '10mb'}))
|
||||
router.use(bodyParser.json({limit: '10mb', extended: false}))
|
||||
router.use(bodyParser.urlencoded({extended: false}))
|
||||
router.use(methodOverride())
|
||||
|
||||
|
@ -469,6 +469,22 @@ describe('Server', function () {
|
||||
})
|
||||
})
|
||||
|
||||
it('should support x-www-form-urlencoded',
|
||||
function (done) {
|
||||
request(server)
|
||||
.post('/posts')
|
||||
.type('form')
|
||||
.send({body: 'foo'})
|
||||
.expect('Content-Type', /json/)
|
||||
.expect({id: 3, body: 'foo'})
|
||||
.expect(201)
|
||||
.end(function (err, res) {
|
||||
if (err) return done(err)
|
||||
assert.equal(db.posts.length, 3)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should respond with json, create a resource and generate string id',
|
||||
function (done) {
|
||||
request(server)
|
||||
|
Reference in New Issue
Block a user