Note that the functionality for creating the many-to-many relationship for products has already been completed for you. Fill Out the API Routes to Perform RESTful CRUD Operationsįill out the unfinished routes in product-routes.js, tag-routes.js, and category-routes.js to perform create, read, update, and delete operations using your Sequelize models. Hint: Make sure you set up foreign key relationships that match the column we created in the respective models. Allow products to have multiple tags and tags to have many products by using the ProductTag through model. Product belongs to many Tag models, and Tag belongs to many Product models. Product belongs to Category, and Category has many Product models, as a category can have multiple products but a product can only belong to one category. You'll need to execute association methods on your Sequelize models to create the following relationships between them: ![]() Your database should contain the following four models, including the requirements listed for each model: Use environment variables to store sensitive data like your MySQL username, password, and database name. Use the schema.sql file in the db folder to create your database with MySQL shell commands. You’ll need to use the MySQL2 and Sequelize packages to connect your Express.js API to a MySQL database and the dotenv package to use environment variables to store sensitive data. Refer to the Fullstack Blog Video Submission Guide for additional guidance on creating a video. This Challenge will require a video submission. Your walkthrough video should also show the POST, PUT, and DELETE routes for products and tags being tested in Insomnia. The following animation shows the application's POST, PUT, and DELETE routes for categories being tested in Insomnia: The following animation shows the application's GET routes to return a single category, a single product, and a single tag being tested in Insomnia: The following animation shows the application's GET routes to return all categories, all products, and all tags being tested in Insomnia: THEN I am able to successfully create, update, and delete data in my database Mock-Up WHEN I test API POST, PUT, and DELETE routes in Insomnia THEN the data for each of these routes is displayed in a formatted JSON WHEN I open API GET routes in Insomnia for categories, products, or tags THEN my server is started and the Sequelize models are synced to the MySQL database ![]() WHEN I enter the command to invoke the application THEN a development database is created and is seeded with test data THEN I am able to connect to a database using Sequelize To get a user's ID, for example, send a request to list the users in your org like you did in the previous section.WHEN I add my database name, MySQL username, and MySQL password to an environment variable file.You can replace URL and body variables with the IDs of the resources that you want to specify. In the upper-right corner, click the box that lists the environments and then select $. Note: You can also download this environment locally and import it as a file.Ĭlick Continue and then Import to confirm your environment import. In the Import dialog box, click Link and then paste the following link into the Enter a URL box. Install the Postman app (opens new window). Each access token enables the bearer to perform specific actions on specific Okta endpoints, with that ability controlled by which scopes the access token contains. This is a feature that allows you to interact with Okta APIs using scoped OAuth 2.0 access tokens. Note: Alternatively, you can create an OAuth 2.0 access token for use with a number of Okta endpoints. When you create a new Okta org, the org is assigned a base URL such as. Don't have one? Create an org for free (opens new window). You need a free Okta developer edition org to get started. ![]() You can then send a test request and verify the results. To use these collections, you need to set up your local environment and import a collection. You can easily use our Postman collections to do just that. A great way to learn an API is to issue requests and inspect the responses.
0 Comments
Leave a Reply. |