Request Body Transformation in Express
📖 Scenario: You are building a simple Express server that receives user data in JSON format. You want to transform the incoming request body to add a new field before processing it further.
🎯 Goal: Build an Express server that accepts JSON data in a POST request, transforms the request body by adding a new field receivedAt with the current timestamp, and then sends back the transformed data as JSON.
📋 What You'll Learn
Create an Express app with JSON body parsing middleware
Add a POST route at
/submit to receive JSON dataAdd a
receivedAt field with the current ISO timestamp to the request bodySend the transformed request body back as JSON in the response
💡 Why This Matters
🌍 Real World
Transforming request bodies is common in APIs to add metadata or normalize data before processing.
💼 Career
Backend developers often need to manipulate incoming data in Express servers to prepare it for storage or further logic.
Progress0 / 4 steps