Junior — Middle
Can you give examples of responses that a server might send after processing a request?
sobes.tech AI
Answer from AI
After processing a request, the server may send different types of responses depending on the result and protocol. Here are some examples:
- 200 OK — the request was successfully processed, and the server returns data (e.g., JSON with information).
- 201 Created — the resource was successfully created (e.g., after a POST request).
- 400 Bad Request — client error, such as an invalid request format.
- 401 Unauthorized — authentication is required.
- 404 Not Found — the requested resource was not found.
- 500 Internal Server Error — an error on the server side.
Example of a JSON response for a successful request:
{
"status": "success",
"data": {
"id": 123,
"name": "Example"
}
}
Such responses help the client understand the result of the operation and handle the data correctly.