LoginSignup
0
0

More than 1 year has passed since last update.

JavaScriptで一定時間待つ処理を入れたい

Posted at

はじめに

Lambdaの関数のテスト目的であえて一定時間待つ処理を入れたかったので、その方法を調べました。

コード

exports.handler = async event => {
  console.log('start timer');
  await delay(5000);
  console.log('After 5 seconds');
};

const delay = time => {
  return new Promise(resolve => setTimeout(resolve, time));
};

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0