内Gupshup.io APIから全体のWebViewのコールバックを読み取ることができません。私は誰かが私は次の入力を受け取ることを期待Gupshup's serverless webview formは、私のクラウド機能
を送信するたびに呼び出されますノードJSで書かれたGoogleのクラウド機能を持っています私のWebサービス:
{
"linkId": "f42414e2-ce1a-4bf5-b40a-e88e4d4d9aee",
"payload": [{
"fieldname": "name",
"fieldvalue": "Alice"
},{
"fieldname": "gender",
"fieldvalue": "Male"
},{
"fieldname": "account",
"fieldvalue": "savings"
},{
"fieldname": "interest",
"fieldvalue": "Cooking"
}],
"time": 1479904354249,
"userid": "UserID"
}
しかし、私はトラブル内のオブジェクトを取得し、 "ペイロード"、時間とユーザーIDのオブジェクトを抱えています。あなたは文字列化は、すべてのペイロードのプロパティを見ることができますが、その前に、私はjsオブジェクトでそれらにアクセスすることはできません見ることができるように
exports.orderForm = (req, res) => {
const data = req.body;
const ref = data.userid;
var propValue;
console.log(req.method); // POST
console.log(req.get('content-type')); // application/x-www-form-urlencoded
console.log(req.body.linkid); // undefined
console.log(req.body.payload[0].fieldname); // cannot read property from undefined error
console.log(req.body.time); //undefined
console.log(req.body.userid); // undefined
// I attemp to print the properties, but they won't print
for(var propName in req.body.payload) {
propValue = req.body.payload[propName];
console.log(propName, propValue);
}
console.log('JSON.stringify: ' + JSON.stringify(req.body)); // This prints the following:
// JSON.stringify: {"{\"linkId\":\"f42414e2-ce1a-4bf5-b40a-e88e4d4d9aee\",\"payload\":":{"{\"fieldname\":\"account\",\"fieldvalue\":\"savings\"},{\"fieldname\":\"name\",\"fieldvalue\":\"Alice\"},{\"fieldname\":\"gender\",\"fieldvalue\":\"Male\"},{\"fieldname\":\"interest\",\"fieldvalue\":\"Cooking\"}":""}}
res.sendStatus(200);
};
:
これは私のコードです。
2番目の問題は、stringify後のイベントは、時刻とユーザーIDが表示されないことです。
content-type = "application/x-www-form-urlencoded"というリクエストは私が以前使っていたものとは違って処理する必要がありますが、そのための例は見つかりませんでした。