Environment Variables allow us to store and retrieve information such as API Keys and Database Passwords from a system. This means we don't have to expose these in our source code. Node can access these from process.env.
let message = { message: "Hello json" };
app.get("/json", (request, response) => {
if (process.env.MESSAGE_STYLE === "uppercase") {
response.json({ message: "HELLO JSON" });
} else {
response.json(message);
}
});
The process.env property returns an object containing the user environment.
Sends a JSON response. This method sends a response (with the correct content-type) that is the parameter converted to a JSON string using JSON.stringify(). The parameter can be any JSON type, including object, array, string, Boolean, number, or null, and you can also use it to convert other values to JSON.
Routes HTTP GET requests to the specified path with the specified callback functions.