Hello,
I have this function, but I keep getting time outs:
import { stripe } from '../../config';
export const getPlans = async ({ forceRefresh = false }) => {
try {
const existingPlans = await getPlansFromCache();
if (!forceRefresh && shouldGetFromCache(existingPlans)) return JSON.parse(existingPlans.Body.toString('utf-8'));
const result = await stripe.plans.list({ limit: 1000 });
const plans = result.data.reduce((acc, plan) => {
const [currency, , planCode] = plan.id.split('-');
const { metadata = {} } = plan;
if (!acc[planCode]) {
return {
...acc,
[planCode]: {
planCode,
},
};
}
return {
...acc,
[planCode]: {
...acc[planCode],
},
};
}, []);
return plans;
} catch (err) {
console.log('Err', err);
return [];
}
};
export default getPlans;
basically, I have a GraphQL endpoint which is executed from my Lambda function using POST method which then sends a request the stripe API to get all available plans, it writes it then writes it to S3.
here is part of my serverless.yml
graphql:
handler: build/main.graphql
timeout: 30
memory: 128
events:
- http:
path: graphql
method: post
cors: true
any advice is much appreciated on how to fix this?