質問編集履歴
1
ご指摘のソースコードを追記しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -60,4 +60,55 @@
|
|
60
60
|
```
|
61
61
|
await db_control.list_albums(body,context);
|
62
62
|
```
|
63
|
+
|
64
|
+
### 追記
|
65
|
+
```
|
66
|
+
"use strict";
|
67
|
+
var AWS = require('aws-sdk');
|
68
|
+
var contents_get = require('./get_contents');
|
69
|
+
var db_control = require('./db_control');
|
70
|
+
|
71
|
+
const crypto = require("crypto");
|
72
|
+
AWS.config.region = 'ap-northeast-1';
|
73
|
+
|
74
|
+
global.messageid;
|
75
|
+
global.userId;
|
76
|
+
exports.handler = async function (event, context) {
|
77
|
+
let body = JSON.parse(event.body);
|
78
|
+
let signature = crypto
|
79
|
+
.createHmac("sha256", process.env.CHANNELSECRET)
|
80
|
+
.update(event.body)
|
81
|
+
.digest("base64");
|
82
|
+
let checkHeader = (event.headers || {})["X-Line-Signature"];
|
83
|
+
|
84
|
+
if (signature === checkHeader) {
|
85
|
+
if (body.events[0].replyToken === "00000000000000000000000000000000") {
|
86
|
+
let lambdaResponse = {
|
87
|
+
statusCode: 200,
|
88
|
+
headers: { "X-Line-Status": "OK" },
|
89
|
+
body: '{"result":"connect check"}',
|
90
|
+
};
|
91
|
+
context.succeed(lambdaResponse);
|
92
|
+
// ③接続確認エラーを確認する。
|
93
|
+
|
94
|
+
} else {
|
95
|
+
body.events.forEach(function(eve) {
|
96
|
+
global.messageid =eve.message.id;
|
97
|
+
global.userId =eve.source.userId;
|
98
|
+
if (eve.message.text === 'アルバム'){
|
99
|
+
global.userId =eve.source.userId;
|
100
|
+
var result =await db_control.list_albums(body); //ここのawaitがエラーになる
|
101
|
+
console.log('result='+ result);
|
102
|
+
}
|
103
|
+
|
104
|
+
});
|
105
|
+
}
|
106
|
+
} else {
|
107
|
+
console.log("署名認証エラー");
|
108
|
+
}
|
109
|
+
};
|
110
|
+
```
|
111
|
+
|
112
|
+
|
113
|
+
|
63
114
|
としてみたのですが、これはエラー(unexpectedtoken)で通りませんでした。
|