Skip to content

Instantly share code, notes, and snippets.

@itaysabato
Created September 16, 2018 14:31
Show Gist options
  • Save itaysabato/511ec7fe89847749e00fdebba51d22d0 to your computer and use it in GitHub Desktop.
Save itaysabato/511ec7fe89847749e00fdebba51d22d0 to your computer and use it in GitHub Desktop.
Simple AWS Lambda function that waits as long as it is told
exports.handler = ({queryStringParameters: {wait}}, context, callback) => {
const response = {
statusCode: 200,
isBase64Encoded: false,
headers: {"Access-Control-Allow-Origin": "*"},
body: JSON.stringify({res: `This has taken ${wait} milliseconds.`}),
};
const startTime = Date.now();
while (Date.now() - startTime < wait) {/** CALCULATING... **/}
callback(null, response);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment