nodejs android post请求 - 无法读取params

时间:2017-08-06 20:50:17

标签: android node.js

我正在尝试从Android应用程序向我的nodejs服务器发出一个帖子请求但是我无法读取我的帖子参数,req.params是空的。任何人都可以给我一些光明吗?非常感谢。

const express = require('express');
var bodyParser = require('body-parser');
bodyParser.urlencoded({ extended: false })
var jsonParser = bodyParser.json();
const router = express.Router();
router.post('/vote', jsonParser,(req, res) =>{
    //do somthing
});
export default router;

//android below
AsyncHttpClient client = new AsyncHttpClient();
        RequestParams params = new RequestParams();
        params.put("test", "a");
        params.put("test2", 223);
        client.post(url2, params, new JsonHttpResponseHandler(){
            @Override
            public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
                Log.wtf("success", "hi: success");
            }
            @Override
            public void onFailure(int statusCode, Header[] headers, String res, Throwable t) {
                // called when response HTTP status is "4XX" (eg. 401, 403, 404)
                Log.wtf("failure", "hi: " + res);
            }
        });

0 个答案:

没有答案