Koa 标准表单 Post with x-www-form-urlencoded

see public/post.html

<script>

$(function(){

$.ajaxSetup({

contentType: "application/x-www-form-urlencoded; charset=utf-8"

});

$.post("/users/post", { name: "i5a6", time: "2pm" },

function(data){

console.log(data);

}, "json");

});

</script>

in routes/users.js

router.post('/post', function(req, res) {

// res.send('respond with a resource');

res.json(req.body);

});

测试

$ npm test

使用 Postman 测试

Koa 标准表单 Post with x-www-form-urlencoded

以上是 Koa 标准表单 Post with x-www-form-urlencoded 的全部内容, 来源链接: utcz.com/z/264477.html

回到顶部