Skip to content

Commit 42cba99

Browse files
committed
update header with apikey
1 parent 81651cf commit 42cba99

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

lambda/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
import { Handler } from "aws-lambda";
2-
import axios, { AxiosHeaders } from 'axios';
2+
import axios from 'axios';
33
import { Payload } from "./types";
44
import { error } from "console";
55

66
const handler: Handler = async (payload: Payload) => {
7-
// const apiKey = process.env.API_Key;
7+
const apiKey = process.env.API_Key;
88
const apiUrl = process.env.API_URL;
99
const { headers, data } = payload;
10-
10+
headers.Authorization = headers.Authorization + apiKey;
1111
try {
1212
if (!apiUrl)
1313
{
1414
throw error;
1515
}
1616
// Make the HTTP request using Axios
1717
const response = await axios.post(apiUrl, data, {
18-
headers: headers as unknown as AxiosHeaders,
18+
headers: headers,
1919
});
2020

2121
if (response.status === 200) {

lambda/types.d.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ export type Text = {
99
}
1010

1111
export type Payload = {
12-
headers: JSON,
12+
headers: {
13+
"Content-Type": string,
14+
"Authorization": string
15+
},
1316
data: JSON ,
1417

1518
}

0 commit comments

Comments
 (0)