When editing a post the changes are not saved to the database.
We need to create a PUT request for post going trough the post domain that saves the edited one in the database.
Further, the endpoint for updating a post will be /posts/{id} and sending a PUT request to this endpoint.
The data in the request body which will be send from frontend to backend will look accordingly:
{
"content": "New content"
}
The response will look like:
{
"id": 1,
"content": "New content",
"createdAt": "2024-10-30T13:43:38.440Z",
"updatedAt": "2024-10-30T13:45:38.440Z", // Will be changed according to when it was updated
"author": {
"id": 1,
"cohortId": 0,
"role": "string",
"firstName": "string",
"lastName": "string",
"bio": "string",
"githubUrl": "string",
"profileImageUrl": "string"
}
}
When editing a post the changes are not saved to the database.
We need to create a PUT request for post going trough the post domain that saves the edited one in the database. Further, the endpoint for updating a post will be /posts/{id} and sending a PUT request to this endpoint. The data in the request body which will be send from frontend to backend will look accordingly:
The response will look like: