相关疑难解决方法(0)

将JSON传递给HTTP POST请求

我正在尝试使用nodejs请求 [2] 向谷歌QPX Express API [1]发出HTTP POST请求.

我的代码如下:

    // create http request client to consume the QPX API
    var request = require("request")

    // JSON to be passed to the QPX Express API
    var requestData = {
        "request": {
            "slice": [
                {
                    "origin": "ZRH",
                    "destination": "DUS",
                    "date": "2014-12-02"
                }
            ],
            "passengers": {
                "adultCount": 1,
                "infantInLapCount": 0,
                "infantInSeatCount": 0,
                "childCount": 0,
                "seniorCount": 0
            },
            "solutions": 2,
            "refundable": false
        }
    }

    // QPX REST API URL (I censored my api …
Run Code Online (Sandbox Code Playgroud)

json curl node.js express node-request

84
推荐指数
4
解决办法
20万
查看次数

标签 统计

curl ×1

express ×1

json ×1

node-request ×1

node.js ×1