Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Set up a data structure on the express server to store information about blog posts made by users of this system. Write a server route
Set up a data structure on the express server to store information about blog posts made by users of this system. Write a server route to handle a HTTP POST request to the path usersaddpost Each POST request should contain JSON of the format title:"sometext", "content":"sometext" When a request to this route is received, the data of the blogpost contained in the POST request should be stored in the above data structure. HINT: this route should go in your users.js file as addpost Write a server route to handle a HTTP GET request to the path usersgetposts A request made to this route should create a JSON response containing the data of all blogposts sent to the server using the above POST route, ordered from newest to oldest. Each GET response should contain JSON of the format title:"newest", "content":"sometext" title:"second", "content":"sometext" title:"first", "content":"sometext" ie an array of blogposts
Set up a data structure on the express server to store information about blog posts made by users of this system.
Write a server route to handle a HTTP POST request to the path usersaddpost
Each POST request should contain JSON of the format title:"sometext", "content":"sometext"
When a request to this route is received, the data of the blogpost contained in the POST request should be stored in the above data structure.
HINT: this route should go in your users.js file as addpost
Write a server route to handle a HTTP GET request to the path usersgetposts
A request made to this route should create a JSON response containing the data of all blogposts sent to the server using the above POST route, ordered from newest to oldest.
Each GET response should contain JSON of the format
title:"newest", "content":"sometext"
title:"second", "content":"sometext"
title:"first", "content":"sometext"
ie an array of blogposts
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started