diff --git a/source/_posts/cron.md b/source/_posts/cron.md index a2f323c..049b9b3 100644 --- a/source/_posts/cron.md +++ b/source/_posts/cron.md @@ -65,8 +65,8 @@ Min Hour Day Mon Weekday | `15 2 * * 1L` | At 2:15am on the last monday of every month | | `15 0 * * 4#2` | At 00:15am on the second thursday of every month | -| `0 0 0 1 * *` | Every 1st of month (monthly) | -| `0 0 0 1 1 *` | Every 1st of january (yearly) | +| `0 0 1 * *` | Every 1st of month (monthly) | +| `0 0 1 1 *` | Every 1st of january (yearly) | | `@reboot` | Every reboot
_(non-standard)_ | diff --git a/source/_posts/javascript.md b/source/_posts/javascript.md index 2bd6891..c29f749 100644 --- a/source/_posts/javascript.md +++ b/source/_posts/javascript.md @@ -1366,6 +1366,29 @@ promise.then(res => { }); ``` +### Fake http Request with Promise + +```javascript +const mock = (success, timeout = 1000) => { + return new Promise((resolve, reject) => { + setTimeout(() => { + if(success) { + resolve({status: 200, data:{}}); + } else { + reject({message: 'Error'}); + } + }, timeout); + }); +} +const someEvent = async () => { + try { + await mock(true, 1000); + } catch (e) { + console.log(e.message); + } +} +``` + JavaScript Async-Await {.cols-2}