docs: general updates to documentation pages (#13055)

This commit is contained in:
Shahed Nasser
2025-07-28 10:52:22 +03:00
committed by GitHub
parent 6e66e36d08
commit cd599e1f62
10 changed files with 234 additions and 138 deletions
@@ -8,7 +8,7 @@ In this chapter, you'll learn how to send a response in your API route.
## Send a JSON Response
To send a JSON response, use the `json` method of the `MedusaResponse` object passed as the second parameter of your API route handler.
To send a JSON response, use the `json` method of the `MedusaResponse` object that is passed as the second parameter of your API route handler.
For example:
@@ -78,7 +78,7 @@ export const streamHighlights = [
["7", "writeHead", "Set the response's headers."],
["7", "200", "Set the status code."],
["8", `"Content-Type"`, "Set the response's content type."],
["13", "interval", "Simulate stream data using an interval"],
["13", "interval", "Simulate stream data using an interval."],
["14", "write", "Write stream data."],
["17", "on", "Stop the stream when the request is terminated."]
]
@@ -109,10 +109,10 @@ export const GET = async (
The `writeHead` method accepts two parameters:
1. The first one is the response's status code.
2. The second is an object of key-value pairs to set the headers of the response.
1. The first parameter is the response's status code.
2. The second parameter is an object of key-value pairs to set the response headers.
This API route opens a stream by setting the `Content-Type` in the header to `text/event-stream`. It then simulates a stream by creating an interval that writes the stream data every three seconds.
This API route opens a stream by setting the `Content-Type` to `text/event-stream`. It then simulates a stream by creating an interval that writes the stream data every three seconds.
---