Node.js REST API
- 38Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
38 questions
- 1The tutorial focuses on creating a vanilla Node.js REST API with full_____functionality, allowing operations like create, read, update, and delete.
Hint
Think about the common acronym for database operations: Create, Read, Update, Delete.
Answer
CRUD
- 2Unlike most Node.js API tutorials that use frameworks like Express, this project utilizes bare bones Node.js with the_____module.
Hint
This module is fundamental for handling web requests and responses in Node.js without a framework.
Answer
http
- 3The project uses a_____file instead of a database to store product information.
Hint
This file format is text-based and commonly used for data interchange.
Answer
JSON
- 4The Node.js_____module is used to read and write data to the JSON file.
Hint
This built-in Node.js module provides an API for interacting with the file system.
Answer
file system
- 5To skip the interactive questions when initializing a new Node.js project, the `npm init_____` command can be used.
Hint
This flag automates the acceptance of default options during initialization.
Answer
-y
- 6The only third-party package used as a development dependency in this project is_____.
Hint
This tool automatically restarts the Node.js application when file changes are detected.
Answer
nodemon
- 7A standard start script for deployment might run_____
node server.js, while the development script useswithnpm run dev.Hint
The tool that automatically watches your files for changes.
Answer
nodemon
- 8The entry point for the Node.js application is the_____file.
Hint
This file typically contains the main logic for starting the server and handling requests.
Answer
server.js
- 9The_____
httpobject in Node.js has a method called `` which is used to kickstart the server and takes a function with request and response objects.Hint
This method creates an instance of an HTTP server.
Answer
createServer
- 10The server's port is set to_____
5000, but it first checks for an environment variable named ``.Hint
This environment variable is commonly used in deployment environments to specify the port.
Answer
PORT
- 11A successful HTTP response that indicates everything is okay typically uses a status code of_____.
Hint
This status code means 'OK' and is common for successful GET requests.
Answer
200
- 12When a resource is successfully created, the HTTP status code commonly used is_____.
Hint
This status code means 'Created' and is typically used after a successful POST request.
Answer
201
- 13A client-side error indicating a 'bad request' typically corresponds to the HTTP status code_____.
Hint
This status code suggests the server cannot or will not process the request due to something that is perceived to be a client error.
Answer
400
- 14An HTTP status code of_____signifies 'not found', meaning the requested resource could not be found.
Hint
This is a very common error message seen when a web page or resource doesn't exist.
Answer
404
- 15Server errors fall within the_____range of HTTP status codes.
Hint
This range of status codes indicates that the server encountered an unexpected condition that prevented it from fulfilling the request.
Answer
500
- 16To send back data as HTML, the_____
Content-Typeheader should be set to ``.Hint
This header value tells the client that the response body contains HTML content.
Answer
text/html
- 17When sending JSON data, the_____
Content-Typeheader should be set to ``.Hint
This header value specifies that the body of the response is JSON formatted.
Answer
application/json
- 18The_____
res.writeHead()method can be used to set both the status code and headers in a single.Hint
This method provides a concise way to configure the initial part of an HTTP response.
Answer
call
- 19When sending JavaScript objects as a JSON response, they must be converted to a JSON string using `_____`.
Hint
This built-in JavaScript method converts a JavaScript value to a JSON string.
Answer
JSON.stringify
- 20To identify the specific resource being requested, the `request._____` property is used, which provides everything past the host in the URL.
Hint
This property of the request object contains the path and query string of the request.
Answer
url
- 21The_____property of the request object is used to determine the HTTP method (e.g., GET, POST, PUT, DELETE) of an incoming request.
Hint
This property tells you what kind of operation the client wants to perform.
Answer
method
- 22The MVC (Model-View-Controller) design pattern is typically divided into three components, with_____handling data and interaction with storage (like a JSON file in this case).
Hint
This component is responsible for managing data and business logic.
Answer
Models
- 23In the MVC design pattern,_____are responsible for controlling what a particular route does, handling status, sending responses, and interacting with the model.
Hint
This component acts as an intermediary between the Model and the View, processing user input.
Answer
Controllers
- 24In the_____
productModel.jsfile, thefindfunction returns a `` because fetching data typically involves asynchronous operations.Hint
This object represents the eventual completion (or failure) of an asynchronous operation and its resulting value.
Answer
Promise
- 25Promises in JavaScript take in a function with_____
resolveand `` as arguments.Hint
These two functions are used to indicate the successful completion or failure of the promise.
Answer
reject
- 26To handle asynchronous operations like fetching data from the model, controller functions are declared as `_____`.
Hint
This keyword allows the use of the
awaitkeyword inside the function.Answer
async
- 27Inside an_____
asyncfunction, the `` keyword is used before a Promise to pause execution until the Promise resolves.Hint
This keyword can only be used inside an
asyncfunction.Answer
await
- 28To extract the ID from a URL like_____
/api/products/123, therequest.urlis split by the/character, and the `` index of the resulting array is taken.Hint
Consider the array indices:
['', 'api', 'products', 'ID'].Answer
3
- 29When creating a new product, a unique ID is generated using the `_____` package.
Hint
This package is commonly used for generating universally unique identifiers.
Answer
uuid
- 30The `_____` operator is used to combine all key-value pairs from an existing product object into a new product object.
Hint
This operator is denoted by three dots
...and is used to expand iterables.Answer
spread
- 31The_____
fs.writeFileSync()method is used inutils.jsto write data to the JSON file.Hint
This means the operation blocks other code execution until it completes.
Answer
synchronously
- 32When writing content to a file, the_____
JSON.stringify()method is used to convert the JavaScript object `` into a JSON string.Hint
The data being written to the file needs to be in a string format suitable for JSON.
Answer
content
- 33When receiving data from a POST request, the_____
request.on('data', ...)event listener accumulates `` that need to be converted to a string.Hint
Data arrives in small pieces or segments.
Answer
chunks
- 34The_____
request.on('end', ...)event listener is triggered when all data from the request `` has been received.Hint
This event signals the completion of data transfer for the request payload.
Answer
body
- 35Before processing, the raw string_____
bodydata from a POST request needs to be parsed into a JavaScript object using ``.Hint
This built-in JavaScript method converts a JSON string into a JavaScript value or object.
Answer
JSON.parse
- 36For_____
update productfunctionality, the `productModel.find` method is used to ensure the product exists before attempting an update.Hint
This method is used to locate a specific product based on its unique identifier.
Answer
ById
- 37When updating a product, the values for title, description, and price are set to either the new value from the body or the_____value if no new value is provided.
Hint
This ensures that fields not explicitly provided in the update request retain their previous data.
Answer
existing
- 38When filtering out a product for deletion, the_____
products.filter()method keeps only those products whoseidisto the ID of the product to be removed.Hint
This logical comparison determines which products should remain in the array.
Answer
not equal

Ask anything
We've read this whole study set, so questions about it get the best answers.