Think you might be in the wrong place? Go home!
In your own words, describe what each group of status code represents:
What is a status code 202?
Accepted Indicates the request was accepted but not yet processed.
What is a status code 308?
Permanent Redirect: Indicates the requested resource has been permanently moved.
What code would you use if an update didn’t return data to a client?
204 (No Content) Indicates a successful request with no content returned.
What code would you use if a resource used to exist but no longer does?
410 (Gone) Indicates the requested resource is no longer available.
403 (Forbidden) Indicates the client lacks necessary permissions.
Storing sensitive information, such as database connection strings, in the .env file adds a layer of security. It keeps sensitive data separate from the codebase and allows developers to use different configurations for development, testing, and production environments without modifying the code.
Middleware is software that acts as a bridge between an application and its database, server, or other components. In the context of web development, middleware functions have access to the request and response objects, and they can perform tasks such as modifying the request, response, or executing additional code before reaching the final route handler.
This middleware in Express.js is used to parse incoming JSON requests. It enables the server to understand and work with JSON data sent in the request body, making it accessible through req.body in route handlers.
It represents a route parameter in Express.js. The value specified in the URL at the position of :id is captured and made available as req.params.id in the route handler. This allows dynamic handling of requests with varying IDs.
PUT: Typically used to update or replace an entire resource. The request payload should contain the complete updated resource.
PATCH: Used to apply partial modifications to a resource. The request payload contains only the changes, allowing for more granular updates.
In a MongoDB schema, you can set a default value for a field using the default property. For example:
const UserSchema = new Schema({
name: {
type: String,
default: 'John Doe',
},
});
A 500 Internal Server Error status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the request. It is a generic error message when the server encounters an error not specifically handled by the application.
Status 200 OK: Indicates that the request was successful.
Status 201 Created: Indicates that the request was successful, and a new resource was created as a result. It is often used in response to successful POST requests to signify the creation of a new resource.
Information gathered using ChatGPT