1 00:00:00,210 --> 00:00:05,440 In this video we're going to take a quick break from building out the rest api and instead we're going 2 00:00:05,440 --> 00:00:08,780 to cover a more advanced promise concept. 3 00:00:08,880 --> 00:00:10,910 This is promise chaining. 4 00:00:10,950 --> 00:00:15,360 So we've had a dozen or so videos to work with the basics of promises. 5 00:00:15,450 --> 00:00:20,730 And every time we've used them we've done just a single asynchronous thing right here. 6 00:00:20,730 --> 00:00:27,170 For example we do one asynchronous thing which is to find a user by their I.D. And down below. 7 00:00:27,170 --> 00:00:29,780 We also do just one asynchronous thing. 8 00:00:29,850 --> 00:00:31,830 We save the new task. 9 00:00:31,980 --> 00:00:38,100 What if we wanted to do one thing and then something else like geo code and address then fetch the weather 10 00:00:38,100 --> 00:00:45,210 for that location or mark a task as complete and then and get the total number of incomplete tasks. 11 00:00:45,210 --> 00:00:51,660 I still have to do in both of those cases we're working with two asynchronous operations where one needs 12 00:00:51,660 --> 00:00:53,820 to happen and then another. 13 00:00:53,820 --> 00:01:00,330 Now promises do provide an advanced syntax for actually getting that done before we worry about integrating 14 00:01:00,330 --> 00:01:02,310 it into our application. 15 00:01:02,310 --> 00:01:05,970 We're going to mess around with it over in the playground directory. 16 00:01:05,970 --> 00:01:07,530 We have that promises file. 17 00:01:07,530 --> 00:01:13,440 We've used plenty of times so far and we're going to spend a little more time in here learning this 18 00:01:13,440 --> 00:01:15,520 advanced syntax as always. 19 00:01:15,540 --> 00:01:21,010 Let's get started with a promise that uses set time out to simulate an asynchronous delay. 20 00:01:21,090 --> 00:01:26,640 Once we're comfortable with the syntax will integrate it back into reality and use it with the promises 21 00:01:26,640 --> 00:01:32,280 that Mongoose provides for the moment though we can just clean this file out and we're going to create 22 00:01:32,310 --> 00:01:40,260 a new function called add add is going to take into numbers we can accept a and b as the parameters 23 00:01:40,290 --> 00:01:47,190 for ADD and over going to do is return a promise after two seconds that promise will be fulfilled with 24 00:01:47,190 --> 00:01:48,200 the sum. 25 00:01:48,210 --> 00:01:51,900 So right here return new promise. 26 00:01:51,960 --> 00:01:54,640 We are going to set up the promise function. 27 00:01:54,660 --> 00:01:59,720 This is where we get access to resolve and reject. 28 00:01:59,820 --> 00:02:07,180 Then we're going to wait those two seconds providing the function to run and the two thousand millisecond 29 00:02:07,210 --> 00:02:08,640 delay down below. 30 00:02:08,860 --> 00:02:14,680 And the last thing we put inside of here is a call to resolve and we're gonna pass in a single argument 31 00:02:14,920 --> 00:02:19,900 the sum of a plus b perfect now that we have this in place. 32 00:02:19,900 --> 00:02:25,390 We know how we could go through the process of using this a single time I could call add passing in 33 00:02:25,390 --> 00:02:33,040 a couple of numbers I'll pass in one end to the sum being three then I can add on my then method call 34 00:02:33,040 --> 00:02:39,310 to do something when the promise is fulfilled and I can add on my catch method call to do something 35 00:02:39,340 --> 00:02:41,410 when that promise is rejected. 36 00:02:41,410 --> 00:02:47,320 So right here I would get access to these sum and I could use it and down below I would get access to 37 00:02:47,320 --> 00:02:53,830 the error and I could go ahead and just log it out now for the moment we'll also log out that sum so 38 00:02:53,830 --> 00:02:55,940 console log sum. 39 00:02:56,220 --> 00:03:01,210 Now I went a little quickly setting that up because this is all stuff we've done before. 40 00:03:01,210 --> 00:03:03,640 From here though we'll be exploring new concepts. 41 00:03:03,640 --> 00:03:09,860 Let's take a quick moment to run the program to make sure it's working before we continue on down below. 42 00:03:09,880 --> 00:03:16,870 I'm gonna shut down node man which is running the task manager app I'll use CDE dot dot forward slash 43 00:03:16,870 --> 00:03:24,700 playground to navigate into the correct directory then we can use node with eight hyphen promises dot 44 00:03:24,700 --> 00:03:25,980 J S. 45 00:03:25,980 --> 00:03:31,360 Now when I run it I would expect to wait for two seconds then see the number three print and that is 46 00:03:31,360 --> 00:03:33,750 exactly what I'm getting right here. 47 00:03:33,940 --> 00:03:39,070 Now in this case we are indeed performing a single asynchronous operation. 48 00:03:39,100 --> 00:03:45,280 We have added two numbers together but we're going to do from here is take that sum and use it with 49 00:03:45,310 --> 00:03:48,980 add again to add another number into the mix. 50 00:03:49,030 --> 00:03:53,890 So that'll be two calls to add or to a synchronous operations. 51 00:03:53,890 --> 00:03:58,150 Now if you didn't know about promise chaining you could still solve this problem. 52 00:03:58,150 --> 00:04:02,330 You would just go where you have the sum and add a another call to add. 53 00:04:02,350 --> 00:04:08,680 Where do I have the sum it's right here inside of this function and I'll add a another call to add I'll 54 00:04:08,680 --> 00:04:15,040 set up the call to add I'll provide these sum as the first argument and I'll provide the other number 55 00:04:15,050 --> 00:04:17,190 I'm trying to add as the second. 56 00:04:17,200 --> 00:04:25,090 In this case 5 I then set up a another call to then right here I get access to what I'll call sum to 57 00:04:25,150 --> 00:04:31,570 the second sum and then I could also add on a catch call to handle any errors from that. 58 00:04:31,570 --> 00:04:38,710 Once again console log the error if anything goes wrong and if I do get that second some a log that 59 00:04:38,710 --> 00:04:40,860 out as well some too. 60 00:04:40,870 --> 00:04:46,690 So right here I've just taken another promise call and I've nested it inside of my first one. 61 00:04:46,720 --> 00:04:50,080 Now if I save the program this is indeed going to work. 62 00:04:50,080 --> 00:04:56,230 I can rerun the script I'll wait two seconds to see the number three and then two more seconds to see 63 00:04:56,230 --> 00:04:57,130 the number eight. 64 00:04:57,160 --> 00:04:58,890 And that's exactly what I get. 65 00:04:58,900 --> 00:05:04,720 Now the problem with the above solution is similar to the problem we ran into when using the callback 66 00:05:04,720 --> 00:05:06,870 pattern without promises. 67 00:05:06,880 --> 00:05:13,540 The problem is that the more asynchronous tasks we try to perform the more nested and complex our code 68 00:05:13,540 --> 00:05:14,430 gets. 69 00:05:14,440 --> 00:05:20,770 For example we're doing two asynchronous tasks so we're two levels deep nested if we were to add on 70 00:05:20,800 --> 00:05:24,700 a another asynchronous call it would get even more complex. 71 00:05:24,700 --> 00:05:29,870 We also have duplicate code for catching errors which is not ideal either. 72 00:05:29,980 --> 00:05:34,520 There's a better way to get it done using something called Promise chaining. 73 00:05:34,600 --> 00:05:40,120 Let's go ahead and explore how we can recreate this example using the new syntax. 74 00:05:40,120 --> 00:05:46,090 What I'm going to do is comment out the example up above the we'll leave it in place so we can compare 75 00:05:46,120 --> 00:05:51,910 and contrast the two solutions to use promise chaining things start off exactly the same. 76 00:05:51,940 --> 00:05:57,760 So I'm still going to call ad and I'm still gonna pick a couple of numbers to add I'll add one and one 77 00:05:57,760 --> 00:06:00,100 for a sum of two right here. 78 00:06:00,130 --> 00:06:03,100 I still call then and I provide my function. 79 00:06:03,100 --> 00:06:09,070 Allowing me to do something when the promise is fulfilled I'll get access to the sum and I'll just keep 80 00:06:09,070 --> 00:06:10,540 the examples consistent. 81 00:06:10,720 --> 00:06:16,980 So right here I am going to log these sum out so we can track things as code runs. 82 00:06:16,990 --> 00:06:23,560 Now we have access to the sum and we want to add that second ad call into the mix when we're using promise 83 00:06:23,620 --> 00:06:24,450 chaining. 84 00:06:24,460 --> 00:06:29,980 What we do is we return the next promise from our then callback. 85 00:06:29,980 --> 00:06:34,350 So right here what I need to do is return a promise. 86 00:06:34,360 --> 00:06:40,480 So what I'm gonna do is return whatever comes back from calling ad which I know is a promise because 87 00:06:40,480 --> 00:06:47,680 I set that function up moments ago and right here what I'm gonna do is add these sum with another number. 88 00:06:47,770 --> 00:06:49,810 So I have these sum which is 2. 89 00:06:49,990 --> 00:06:53,890 I'll go ahead and add 4 for a total of 6. 90 00:06:53,890 --> 00:07:00,730 Now the question is Where do we put our other then call in the previous example we put it inside of 91 00:07:00,730 --> 00:07:07,020 the other callback and that's what created this problem where we had all of these nested callback functions 92 00:07:07,320 --> 00:07:13,680 where each asynchronous process would get us further and further nested as we moved on with promise 93 00:07:13,680 --> 00:07:18,830 chaining and he's second then call comes right here after the first. 94 00:07:18,840 --> 00:07:23,900 So then we then get access to the result of that promise. 95 00:07:23,910 --> 00:07:27,640 The result of this promise right here being fulfilled. 96 00:07:27,810 --> 00:07:30,150 I'm going to call that sum too. 97 00:07:30,210 --> 00:07:36,270 I'll set up my then call and right here I'm just going to console not log it to the terminal like I 98 00:07:36,270 --> 00:07:38,880 had done in my example up above. 99 00:07:38,880 --> 00:07:45,450 So this is promise chaining in effect it's chaining because what I'm doing is chaining together multiple 100 00:07:45,480 --> 00:07:48,930 then calls each working with a different promise. 101 00:07:49,000 --> 00:07:53,900 The first then call runs when this promise right here is fulfilled. 102 00:07:53,970 --> 00:08:00,930 The second then call runs when this promise right here is fulfilled and we could add on a catch call 103 00:08:00,930 --> 00:08:03,560 at the end to catch those errors. 104 00:08:03,570 --> 00:08:10,170 So right here I'm going to provide a function similar to what I had up above but I'm going to provide 105 00:08:10,170 --> 00:08:13,060 it just a single time console log. 106 00:08:13,170 --> 00:08:16,320 Printing any potential errors to the screen. 107 00:08:16,320 --> 00:08:20,460 Now the nice thing about promised chaining is our code is not nested. 108 00:08:20,460 --> 00:08:27,420 I could chain together 400 calls to add and it would never get nested imagine 400 calls to add. 109 00:08:27,480 --> 00:08:35,310 Using the example up above now 400 is a bit extreme but even with 2 it's clear that we have advantages 110 00:08:35,550 --> 00:08:40,180 and if we added a third into the mix it would be even more advantageous. 111 00:08:40,200 --> 00:08:44,840 Let's go ahead and run the program to make sure it's still working up and then enter. 112 00:08:44,850 --> 00:08:48,020 Right here we wait are two seconds for the number two. 113 00:08:48,030 --> 00:08:51,590 Then we wait two more seconds for the number six. 114 00:08:51,600 --> 00:08:57,480 So right here with promise chaining we're able to achieve something similar to what we had above. 115 00:08:57,570 --> 00:09:04,260 But with an improved syntax all you need to know is that you can return a promise from one of your then 116 00:09:04,260 --> 00:09:09,090 callbacks allowing you to chain a another then call on. 117 00:09:09,090 --> 00:09:13,290 So that is the promise chaining syntax in isolation. 118 00:09:13,290 --> 00:09:16,440 Let's go ahead and actually use it with our tasks. 119 00:09:16,470 --> 00:09:19,620 Now there's not a real use case for it just yet. 120 00:09:19,620 --> 00:09:21,650 Inside of our rest api. 121 00:09:21,750 --> 00:09:27,540 So what we're actually going to do is create a new directory any task manager folder. 122 00:09:27,660 --> 00:09:34,590 Right here I'm going to create a new folder and we're going to create a playground a directory specific 123 00:09:34,650 --> 00:09:42,540 to the task manager app and in there we're going to create a new file called Promise hyphen chaining 124 00:09:42,770 --> 00:09:50,280 dot J S and we're going to use this file to explore how we can work with Mongoose promises any chaining 125 00:09:50,340 --> 00:09:51,470 syntax. 126 00:09:51,480 --> 00:09:54,300 Now we only need two things inside of here. 127 00:09:54,300 --> 00:10:00,120 First up I do need to require that Mongoose file to connect to the database. 128 00:10:00,330 --> 00:10:03,550 That's C D excuse me not C D. 129 00:10:03,580 --> 00:10:11,430 Just dot dot forward slash source forward slash D.B. forward slash mongoose. 130 00:10:11,430 --> 00:10:16,140 Now that we have the database connection we want to grab the model we'll be working with. 131 00:10:16,170 --> 00:10:24,090 I'll be working with the user so I'll require that as well dot dot forward slash source forward slash 132 00:10:24,120 --> 00:10:27,130 models forward slash user. 133 00:10:27,150 --> 00:10:33,330 So now we have access to the user and we're gonna go ahead and use a couple of new queries that Mongoose 134 00:10:33,360 --> 00:10:36,050 supports to do something interesting. 135 00:10:36,150 --> 00:10:42,540 What I'm going to do is change the age for a user then I'm going to fetch the total number of other 136 00:10:42,540 --> 00:10:45,210 users that have that same age. 137 00:10:45,210 --> 00:10:49,260 Let's start by grabbing the I.D. of the user we're trying to update. 138 00:10:49,290 --> 00:10:57,090 So over in robo 3 T we can grab any of our user I.D. I'll switch over to the table view now the age 139 00:10:57,090 --> 00:10:59,670 for every single user is zero. 140 00:10:59,730 --> 00:11:05,190 So it doesn't really matter which one I update I'm going to right click one of my documents click edit 141 00:11:05,190 --> 00:11:12,120 document and I'm going to copy the string object I.D. to the clipboard we can bring that over to visual 142 00:11:12,120 --> 00:11:18,120 studio code and I'll go ahead and just paste it right here and a comment and we'll use it in a moment. 143 00:11:18,120 --> 00:11:23,820 Next up we have to figure out which Mongoose methods we're actually gonna use to get all of this done. 144 00:11:23,850 --> 00:11:30,660 For that we want to head back over to the documentation in the browser and under that queries documentation 145 00:11:30,720 --> 00:11:34,770 where we were before we have a few different options for doing this. 146 00:11:34,830 --> 00:11:43,400 I have Update 1 and update many but I also have find one and update and find by I.D. And update now 147 00:11:43,410 --> 00:11:48,210 they find variations simply return the document as well. 148 00:11:48,360 --> 00:11:54,270 So these ones down below they're not going to give you the document back find by I.D. and update will 149 00:11:54,420 --> 00:11:56,940 and so will find one and update. 150 00:11:57,360 --> 00:11:58,440 So it's really up to you. 151 00:11:58,440 --> 00:12:00,260 Which one you choose to use. 152 00:12:00,270 --> 00:12:07,860 I'm gonna go ahead and use find by I.D. and update so I'll click that to get brought over to the documentation. 153 00:12:07,890 --> 00:12:10,420 Now we can go ahead and actually use this. 154 00:12:10,440 --> 00:12:20,460 We are going to call user dot find by I.D. and update and the first argument we provide is our I.D.. 155 00:12:20,460 --> 00:12:22,500 So I have the I.D. right here. 156 00:12:22,620 --> 00:12:24,000 I'm going to cut it out. 157 00:12:24,000 --> 00:12:30,930 Remove the extra lines and I'll paste it right inside of a string as the first argument to our method. 158 00:12:30,930 --> 00:12:36,800 Now the second argument is the object which contains the updates we want to apply in this case. 159 00:12:36,810 --> 00:12:41,130 I'm going to set the user's age from zero over to 1. 160 00:12:41,130 --> 00:12:44,280 Now you'll notice that I'm not using that dollar sign set. 161 00:12:44,310 --> 00:12:44,750 Update. 162 00:12:44,750 --> 00:12:51,750 Operator we explored with the Mongo D.B. native driver the Mongoose library actually takes care of this 163 00:12:51,750 --> 00:12:55,290 for us so we don't have to do that which is a nice feature. 164 00:12:55,290 --> 00:12:57,890 Next up we can go ahead and use then. 165 00:12:57,960 --> 00:13:04,870 So dot then to run some code when we have found an updated given document. 166 00:13:05,100 --> 00:13:06,830 I'm gonna have access to that. 167 00:13:06,870 --> 00:13:10,490 I can call this something like user ID down below. 168 00:13:10,500 --> 00:13:13,270 All I'm going to do is print them to the console. 169 00:13:13,290 --> 00:13:15,420 Excellent from here. 170 00:13:15,420 --> 00:13:22,050 We want to perform that second asynchronous operation which is to count up all of the users that have 171 00:13:22,050 --> 00:13:29,880 that same age so all users whose age is 1 Mongoose provides us with a method to get that done as well. 172 00:13:29,880 --> 00:13:36,120 Now over and that queries documentation they show us a list of methods that are available on our model. 173 00:13:36,120 --> 00:13:37,740 This is not a complete list. 174 00:13:37,740 --> 00:13:43,310 This is just some of the most popular ones that are used to get common tasks done. 175 00:13:43,320 --> 00:13:49,400 This is in the guides documentation which is more like a tutorial down below an API. 176 00:13:49,410 --> 00:13:53,940 We get the actual implementation for every single method available. 177 00:13:53,940 --> 00:13:58,550 If we click on model we can explore these as well as many others. 178 00:13:58,560 --> 00:14:03,030 So I'm going to navigate over to the model API docs and down below. 179 00:14:03,030 --> 00:14:07,150 We have a bunch of different ones including the one that we just used. 180 00:14:07,170 --> 00:14:11,340 Find by I.D. and update sitting right here now. 181 00:14:11,370 --> 00:14:15,040 The method that we're here to use is up top a little bit. 182 00:14:15,090 --> 00:14:17,670 It is called Count documents. 183 00:14:17,670 --> 00:14:23,670 Now we also have a count but count is deprecated and it'll be going away at some point in the future 184 00:14:23,910 --> 00:14:24,210 count. 185 00:14:24,240 --> 00:14:28,830 Documents is going to allow us to count up the number of documents now. 186 00:14:28,860 --> 00:14:34,920 Right here we can see they have an adventure model and they're trying to find the amount of adventures 187 00:14:34,920 --> 00:14:36,990 that have a type of jungle. 188 00:14:37,050 --> 00:14:44,730 We're gonna do something similar but with an age of 1 for the user model over inside of promise chaining. 189 00:14:44,860 --> 00:14:46,360 J.S. let's get this done. 190 00:14:46,380 --> 00:14:49,580 Now remember the whole goal is to use chaining. 191 00:14:49,590 --> 00:14:52,860 So I want to return the next promise. 192 00:14:52,860 --> 00:15:00,030 Return user dot count documents and account documents. 193 00:15:00,030 --> 00:15:02,550 Works by accepting an object. 194 00:15:02,580 --> 00:15:09,090 Right here we provide our filter where age equals 1 and what we eventually get back. 195 00:15:09,150 --> 00:15:11,520 The promise is fulfilled with the account. 196 00:15:11,520 --> 00:15:17,120 So right here I'll add on my second then call chaining it on to the first. 197 00:15:17,280 --> 00:15:23,460 I'll set up my callback function and then we're gonna go ahead and get access to the result and we'll 198 00:15:23,460 --> 00:15:24,690 print it to the terminal 199 00:15:27,240 --> 00:15:28,190 Excellent. 200 00:15:28,200 --> 00:15:28,800 Down below. 201 00:15:28,800 --> 00:15:30,260 We'll also set up a catch. 202 00:15:30,260 --> 00:15:36,240 Call at the very end to handle any errors from either of those two promises up above. 203 00:15:36,240 --> 00:15:42,480 Right here I'll set that up and I'll use console dot log with e to get that done. 204 00:15:42,480 --> 00:15:43,310 Perfect. 205 00:15:43,380 --> 00:15:48,300 So now that we have this in place we can actually test our work and make sure everything's actually 206 00:15:48,300 --> 00:15:51,180 functioning down below from the terminal. 207 00:15:51,180 --> 00:15:58,740 We need to navigate out of the playground directory so C D dot dot and back over to the task manager 208 00:15:58,830 --> 00:15:59,560 app. 209 00:15:59,640 --> 00:16:02,520 Once we're here we'll go ahead and run the new file. 210 00:16:02,520 --> 00:16:07,380 That would be node playground forward slash promise chaining. 211 00:16:07,470 --> 00:16:10,390 J.S.. 212 00:16:10,630 --> 00:16:14,350 Now when we run the script we're gonna get some interesting output. 213 00:16:14,350 --> 00:16:20,350 The first thing we're gonna see is actually a deprecation warning which we'll address in just a moment. 214 00:16:20,350 --> 00:16:23,030 After that we get the document that we found. 215 00:16:23,110 --> 00:16:26,230 So that's printing from line 5 which looks great. 216 00:16:26,290 --> 00:16:30,230 And then after that we get the number one that is the count. 217 00:16:30,340 --> 00:16:32,800 There is one user with an age of 1. 218 00:16:32,830 --> 00:16:35,890 It is the user that I just updated. 219 00:16:35,890 --> 00:16:39,740 Now let's take another user I.D. and update them as well. 220 00:16:39,790 --> 00:16:44,620 So if I refresh my data over here I can see they now have an age of 1. 221 00:16:44,620 --> 00:16:51,550 I'll grab some other user with an age of 0 added them just to grab their I.D. and then we'll bring that 222 00:16:51,550 --> 00:16:55,300 I.D. over to visual studio code from here. 223 00:16:55,300 --> 00:17:02,480 I'll swap out the old user I.D. with the new one I'm gonna save the program and rerun it a second time. 224 00:17:02,620 --> 00:17:05,760 This time we're gonna see that the count is now 2. 225 00:17:05,830 --> 00:17:08,130 There are two users with the age of 1. 226 00:17:08,230 --> 00:17:14,200 The one I had changed a few moments ago and the one that I changed just now. 227 00:17:14,200 --> 00:17:19,510 So right here we can see how we can use promise chaining to do one thing after another. 228 00:17:19,510 --> 00:17:24,080 Now let's wrap up by talking about this deprecation warning that we're getting right here. 229 00:17:24,100 --> 00:17:30,660 Deprecation warning collection dot find and modify is deprecated then it offers up some alternatives 230 00:17:30,670 --> 00:17:32,410 we could use instead. 231 00:17:32,410 --> 00:17:37,630 So find and modify is deprecated because there's better alternatives and it's eventually going to go 232 00:17:37,630 --> 00:17:38,500 away. 233 00:17:38,500 --> 00:17:41,920 Now this is not something we ever typed out in our code. 234 00:17:41,920 --> 00:17:48,210 It's actually coming from the Mongo D.B. native driver that mongoose is using behind the scenes. 235 00:17:48,550 --> 00:17:53,240 So the Mongo DB native driver will change how things get done. 236 00:17:53,290 --> 00:17:58,870 They'll deprecate old methods and introduce new ones and it takes Mongoose a little bit of time to get 237 00:17:58,870 --> 00:17:59,640 up to speed. 238 00:17:59,680 --> 00:18:02,220 So you'll see these warnings every once in a while. 239 00:18:02,260 --> 00:18:05,440 Now it's very possible you're not even seeing this warning. 240 00:18:05,440 --> 00:18:12,340 That's OK if you are you can always address it by going into Mongoose and setting up a no other option 241 00:18:12,550 --> 00:18:16,530 similar to what we did with use knew you are El parser. 242 00:18:16,540 --> 00:18:24,850 That means we'll be setting up a third of property on this object and this one is called use bind and 243 00:18:24,910 --> 00:18:28,660 modify and that is set to true by default. 244 00:18:28,750 --> 00:18:33,970 We're going to set that to false which will address the deprecation warning until it's addressed by 245 00:18:33,970 --> 00:18:35,170 default. 246 00:18:35,170 --> 00:18:40,170 Now if we save Mongoose dot J S we can go ahead and rerun these script down below. 247 00:18:40,180 --> 00:18:46,240 By shutting it down and starting it up once again and now we have no deprecation warnings in sight which 248 00:18:46,240 --> 00:18:47,350 is nice. 249 00:18:47,350 --> 00:18:51,310 So at this point we've got a basic rundown on promise chaining. 250 00:18:51,310 --> 00:18:57,850 It took a little while but I wanted to go through two examples one using fake asynchronous operations 251 00:18:57,850 --> 00:19:03,720 with set time out and another using real asynchronous operations in the next video. 252 00:19:03,730 --> 00:19:07,900 There'll be a challenge where you're gonna have to use promise chaining on your own. 253 00:19:07,900 --> 00:19:09,150 I'm excited to get to it. 254 00:19:09,190 --> 00:19:10,500 So let's jump right in.