JSON.parseするの忘れてただけだった....すみません........
LINE Messaging APIを AWS API Gateway, Lambdaを使って叩いています。
タイトルにある通り、body部の中身がjsonではなくひとまとまりの文字列となって格納されており、困っております。 聞きたいことは、
- 5月段階で別のアプリケーションを使っていた際はjsonが渡されていた。今回の事象はバグではないのか?
- 解決方法はないか、制御する何かしらの設定がないのか
の二つです。
console.logで出力した結果はこちらになります。ご参考までに。 https://cdn-ak.f.st-hatena.com/images/fotolife/h/hazeblog/20180729/20180729120324.png https://cdn-ak.f.st-hatena.com/images/fotolife/h/hazeblog/20180729/20180729120329.png
利用したソースコードは以下になります。
'use strict';
exports.handler = async function (event, context) { console.log('event: ' + JSON.stringify(event)) console.log('context: ' + JSON.stringify(context)) console.log('body: ' + JSON.stringify(event.body))
let lambdaResponse = { statusCode: 200, headers: { "X-Line-Status": "OK" }, body: '{ "result": "connect check" }' } context.succeed(lambdaResponse)
}