Question: 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
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
