-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasync.js
More file actions
47 lines (40 loc) · 1007 Bytes
/
async.js
File metadata and controls
47 lines (40 loc) · 1007 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// var arr = ["Яблоко", "Апельсин", "Груша"];
//const { reject } = require("async");
// arr.forEach(function(item, i, arr) {
// alert( i + ": " + item + " (массив:" + arr + ")" );
// });
console.log('Request data...');
// setTimeout(() => {
// console.log('Preparing data...')
// const backendData = {
// server: 'aws',
// port: 2000,
// status: 'working'
// }
// setTimeout(() => {
// backendData.modified = true
// console.log('Data received', backendData);
// }, 2000)
// }, 2000)
const p = new Promise((resolve, reject) => {
setTimeout(() => {
console.log('Preparing data...')
const backendData = {
server: 'aws',
port: 2000,
status: 'working'
}
resolve(backendData)
},2000)
})
p.then((data) => {
const p2 = new Promise((resolve, reject) => {
setTimeout(() => {
data.modified = true
resolve(data)
}, 2000)
})
p2.then(clientData => {
console.log('Data received', clientData);
})
})