-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallback.js
More file actions
61 lines (52 loc) · 1.08 KB
/
callback.js
File metadata and controls
61 lines (52 loc) · 1.08 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const prop1 = false;
const prop2 = false;
const callback = (resFn, errFn) => {
// in a func the arguments are also function
// e.g res,err
if (prop1) {
errFn({
name: "prop1",
message: "this is error message of prop1",
});
} else if (prop2) {
errFn({
name: "prop2",
message: "this is error message of prop2",
});
} else {
resFn("Everything is working");
}
};
callback(
(resArgument) => {
console.log(resArgument);
},
(errArgument) => {
console.log(`${errArgument.name} ${errArgument.message}`);
}
);
// abc((err, result) => {
// if (err) throw Error;
// else {
// console.log(result);
// def(result, (err, res2) => {
// xyz(result, res2, (err, res3) => {
// if (err) {
// res.status(400).json({
// error: err
// })
// }
// res.status(200).json({
// result: res3
// })
// })
// })
// }
// })
let user = {
name: "Sanchit",
email: "sanchitbajaj02@gmail.com",
password: "12345",
number: "45204208",
};
console.log(user);