Skip to content

Commit

Permalink
update header with apikey
Browse files Browse the repository at this point in the history
  • Loading branch information
Claude-GP committed Jan 30, 2024
1 parent 81651cf commit 42cba99
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lambda/index.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { Handler } from "aws-lambda";
import axios, { AxiosHeaders } from 'axios';
import axios from 'axios';
import { Payload } from "./types";
import { error } from "console";

const handler: Handler = async (payload: Payload) => {
// const apiKey = process.env.API_Key;
const apiKey = process.env.API_Key;
const apiUrl = process.env.API_URL;
const { headers, data } = payload;

headers.Authorization = headers.Authorization + apiKey;
try {
if (!apiUrl)
{
throw error;
}
// Make the HTTP request using Axios
const response = await axios.post(apiUrl, data, {
headers: headers as unknown as AxiosHeaders,
headers: headers,
});

if (response.status === 200) {
Expand Down
5 changes: 4 additions & 1 deletion lambda/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ export type Text = {
}

export type Payload = {
headers: JSON,
headers: {
"Content-Type": string,
"Authorization": string
},
data: JSON ,

}

0 comments on commit 42cba99

Please sign in to comment.