I'm new to AWS including Lambda (and stack over flow for that matter so go easy on me please). I want to be able to get data requests from https://rapidapi.com/api-sports/api/api-football and post the results to my S3 or Dynamo DB instances.
I've attempted creating an AWS Lambda URL function which only succeeds in returning null results. I have tried looking for a straight forward explanation of how to achieve this but im a bit stumped.
So i created a test Lambda URL function by copying the API code supplied by Rapid API (node JS fetch). I pasted it under this line of code export const handler = async(event) => {
So i ended up with this code
export const handler = async(event) => {
const options = {
method: 'GET',
headers: {
'X-RapidAPI-Host': 'api-football-v1.p.rapidapi.com',
'X-RapidAPI-Key': 'MY API KEY',
Authorization: 'Basic Og=='
}
};
fetch('https://api-football-v1.p.rapidapi.com/v3/players?team=42&season=2022&search=saka', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err))};
I also added the JSON schema provided by rapid API
I run the test in AWS and it says its succeeded but i get the below message and it returns null.
Test Event Name JSON
Response null
Function Logs
START RequestId: bfb5ddd4-56f8-466a-b3c1-7ed89f3edc2b Version:
$LATEST
2022-11-24T16:07:33.622Z
203cdbbc-a661-4256-91bb-2ada34d53042
ERROR TypeError: fetch failed
at Object.fetch (node:internal/deps/undici/undici:11118:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
cause: ConnectTimeoutError: Connect Timeout Error
at onConnectTimeout (node:internal/deps/undici/undici:6625:28)
at node:internal/deps/undici/undici:6583:50
at Immediate._onImmediate (node:internal/deps/undici/undici:6614:13)
at process.processImmediate (node:internal/timers:471:21) {
code: 'UND_ERR_CONNECT_TIMEOUT'
}
}
END RequestId: bfb5ddd4-56f8-466a-b3c1-7ed89f3edc2b
REPORT RequestId: bfb5ddd4-56f8-466a-b3c1-7ed89f3edc2b Duration: 194.65 ms Billed Duration: 195 ms Memory Size: 128 MB Max Memory Used: 73 MB
Request ID bfb5ddd4-56f8-466a-b3c1-7ed89f3edc2b
Would anyone know what im doing wrong or be able to point me in the right direction?