WEBVTT 00:00.660 --> 00:06.000 So we have our database function, and the next step is to set up a root and a handler on the API so 00:06.000 --> 00:06.940 we can use that function. 00:06.960 --> 00:08.050 And that's pretty straightforward. 00:08.490 --> 00:15.060 So I'm looking at Route's Dash API Dutko and in this section on line thirty two in my code, I'll add 00:15.060 --> 00:19.200 a route that is protected for admin users only. 00:19.290 --> 00:20.250 I don't make a post route. 00:20.430 --> 00:27.030 It could be a cat, but I'm going to make it a post and I'll just call API admin, which we get from 00:27.030 --> 00:32.190 line thirty two and then all the sales, which could be all orders. 00:32.200 --> 00:39.090 But I'm going to go with sales and I'll call a handler that doesn't exist yet called at all sales and 00:39.090 --> 00:44.670 I will go create that handler some over two handlers API and I'll put it at the very bottom of this 00:44.670 --> 00:51.780 function or this file and I'll create a funk with the receiver of the application and I'll call it all 00:51.790 --> 00:54.360 sales and it's a handler. 00:54.360 --> 00:59.700 So we'll give it its response rate and it's a pointer to a request. 01:01.230 --> 01:02.280 And this is dead simple. 01:02.400 --> 01:08.580 All we do here is, say, all sales, which is a variable I'm declaring right here and potentially an 01:08.580 --> 01:15.870 error come from after DB get all orders with no parameters. 01:15.870 --> 01:16.620 Check for an error. 01:17.430 --> 01:18.930 If error is not equal to nil. 01:23.580 --> 01:31.440 All I'll do right now is just say after that request and that requires w are in the error return. 01:32.580 --> 01:37.860 But if we get past that point then we can send JSON back, which is a simple now as going right Jason. 01:38.910 --> 01:41.520 And handing it W status. 01:41.520 --> 01:48.310 OK, or whatever status you choose to use and the variable or sales and that should be it. 01:48.570 --> 01:54.960 So now we should be able to go and write some JavaScript on the front end to call this handler, which 01:54.960 --> 02:00.250 gets all the sales and returns and was chosen, and we'll get started on that in the next election.