part 20…
A small bug, lets get this started. Inside the request handler we are getting access to the errors object, but we arent doing anyhting with it at this point. If you remember, inside the auth.js file we are taking that errors object and reunning a check to see if its empty, if not , the we want to pass the right error. We want to do that in our products creation route handler as well…
Here we are again saying, if the errors object comes back not empty then send the new products template back with the appropriate errors. Then, we need to adjust the new products template to show those…
And here if we save and go back to our form in the browser and give this a test…
We see a weird error… I entered a valid title, that is to say one over 5 characters and under 40, a valid number, and selected a valid .png from my desktop… essentially, the request is not being properly parsed, so to fix this, we need to reorder the steps in the post request…
All that we did here, was switch lines 20, 21… we want the new form to be parsed with the multi parser before being validated, or all we will get back is the text outputs, from the multi-parser. It seems a little bizarre, but it is important that the middleWares run in the proper order. And now retest with the same info and…
A new product created… a small bug, fixed. And now a little bit of styling.
With just a few additions we can make our plan ugly form start to look decent…
Start in the new product form and add a few classes and…
and after adding all the new classes in…
Not too shabby.. the rest of the code looks like this now…
And one last touch with our errors…
And finally…
A small bug, a small bit of styling, and we have a good place to break, we’re getting really close to putting this all together!