• 10 hours
  • Medium

Free online content available in this course.



Got it!

Last updated on 2/21/22

Can you implement CRUD?

Evaluated skills

  • Create a RESTful web API using Node, Express and MongoDB


To answer the single question in this quiz, you must code a fully functioning API like the one we already created. Your API will also need to be connected to a database, as you will test various CRUD operations!

You will create a basic API for an online store that allows users to create, read, update, and delete products (  Product  ) from a database. Each  Product  must have the following four fields:

  • name  : the name of the product, of type  String  .
  • description  : the description of the product, of type  String .
  • price  : the price of the product, of type  Number  .
  • inStock  : whether the product is in stock or not, of type  Boolean  .

You will implement five routes:

  • GET  /api/products
    Returns all products in the database as  { products: Product[] }  .
  • GET  /api/products/:id
    Returns the product with the provided  _id  as  { product: Product }  .
  • POST  /api/products
    Creates a new product in the database
    The request body must contain:
    "name": string,
    "description": string,
    "price": number,
    "inStock": boolean

Returns the new product (including its  _id  field) as  { product: Product }  .

  • PUT  /api/products/:id
    Updates the product with the provided  _id  with the data provided in the request body.
    The request body must contain:
        "name": string,
        "description": string,
        "price": number,
        "inStock": boolean
    Returns the following object:  { message: 'Modified!' }
  • DELETE  /api/products/:id
    Deletes the product with the provided   _id  .
    Returns the following object:  { message: 'Deleted!' }  .

Your API will run on your local machine on  localhost  (preferably on port 3000, but the front-end app allows you to modify the port number if necessary) and accept HTTP requests from all origins (don't forget your CORS configuration!).

To test your API, you will need to install a small front-end app. Clone the repo with the frontend code following this link.

From within the cloned directory, run  npm install  , followed by  npm start  . Your browser should open to this interface:

Front end app

With your server running, click the TEST ROUTES button to run the tests. These tests will allow you to check that you have correctly implemented the required routes and whether you have validated this quiz!  Success or error messages will display as each test passes or fails to inform you which routes work and which do not.


  • Question 1

    When all tests pass successfully, a secret word is displayed. Which of the following is that secret word?




    • ZEBRA

Ever considered an OpenClassrooms diploma?
  • Up to 100% of your training program funded
  • Flexible start date
  • Career-focused projects
  • Individual mentoring
Find the training program and funding option that suits you best