Merge remote-tracking branch 'origin/main'

This commit is contained in:
fechin committed 2023-02-26 14:32:56 +08:00
commit 857d31fcba
2 files changed
+25 -2

No files matched your search

+2 -2
View File
@@ -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 <br>_(non-standard)_ |
+23
View File
@@ -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}