Persisting new products to the database
At this point, our client-side changes for the admin panel are near enough complete, and if you run the application now, you should be able to browse to the admin panel, view a list of orders and existing products, and fill in the create product form to see our custom input controls in action. However, if you try to save a product that passes client-side validation, nothing will happen as the API endpoint we told it to send to does not yet exist. We'll fix that now.
Creating a slug generator
In order to support SEO-friendly URLs in our product catalogue, we rely on identifying specific products by their URL slug
property. For example, when accessing a page with a relative path of /products/soylent-megafone
, the slug that we extract is soylent-megafone
. This is what we pass back to our API endpoint to fetch the specific products details. So far, these properties have been hardcoded into our seed data method, so how do we slugify a product name so that...