File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change 1
1
import { Handler } from "aws-lambda" ;
2
- import axios , { AxiosHeaders } from 'axios' ;
2
+ import axios from 'axios' ;
3
3
import { Payload } from "./types" ;
4
4
import { error } from "console" ;
5
5
6
6
const handler : Handler = async ( payload : Payload ) => {
7
- // const apiKey = process.env.API_Key;
7
+ const apiKey = process . env . API_Key ;
8
8
const apiUrl = process . env . API_URL ;
9
9
const { headers, data } = payload ;
10
-
10
+ headers . Authorization = headers . Authorization + apiKey ;
11
11
try {
12
12
if ( ! apiUrl )
13
13
{
14
14
throw error ;
15
15
}
16
16
// Make the HTTP request using Axios
17
17
const response = await axios . post ( apiUrl , data , {
18
- headers : headers as unknown as AxiosHeaders ,
18
+ headers : headers ,
19
19
} ) ;
20
20
21
21
if ( response . status === 200 ) {
Original file line number Diff line number Diff line change @@ -9,7 +9,10 @@ export type Text = {
9
9
}
10
10
11
11
export type Payload = {
12
- headers : JSON ,
12
+ headers : {
13
+ "Content-Type" : string ,
14
+ "Authorization" : string
15
+ } ,
13
16
data : JSON ,
14
17
15
18
}
You can’t perform that action at this time.
0 commit comments