Skip to content

Week 2 homework#11

Open
AlfiYusrina wants to merge 2 commits into
dfdeagle47:masterfrom
AlfiYusrina:week2
Open

Week 2 homework#11
AlfiYusrina wants to merge 2 commits into
dfdeagle47:masterfrom
AlfiYusrina:week2

Conversation

@AlfiYusrina
Copy link
Copy Markdown

I haven't been able to finish the GET/delete, hopefully, I fix this by tomorrow.

@dfdeagle47
Copy link
Copy Markdown
Owner

Good job so far.

Here are some additional pointers

  • GET /posts: right now you're returning HTML (with the div, h1, li, etc.). When you're doing a REST API, you will instead return raw JavaScript objects using JSON. The rendering with the HTML will be done client-side: it gets the raw data, and processes it to transform to HTML according the client-side application logic. You will explore the client-side part when doing the React module. In the meantime, you can just send the JavaScript objects from the server.
  • GET /posts/:postId : looks good. Same remark as above: just send the JavaScript object directly.
  • GET /posts/:postId/delete : you will have to remove the post from the array. One way to do this is to create a new array without the deleted post and change the value of the posts variable (you might have to change const posts = ... to let posts = ... in the code to do this). You should look at the array methods which might let you do this (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants