You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/2.utils/2.reponse.md
+7
Original file line number
Diff line number
Diff line change
@@ -63,12 +63,15 @@ Remove a response header by name.
63
63
### `send(event, data?, type?)`
64
64
65
65
Directly send a response to the client.
66
+
66
67
**Note:** This function should be used only when you want to send a response directly without using the `h3` event. Normaly you can directly `return` a value inside event handlers.
67
68
68
69
### `sendIterable(event, iterable)`
69
70
70
71
Iterate a source of chunks and send back each chunk in order. Supports mixing async work toghether with emitting chunks.
72
+
71
73
Each chunk must be a string or a buffer.
74
+
72
75
For generator (yielding) functions, the returned value is treated the same as yielded values.
73
76
74
77
**Example:**
@@ -97,17 +100,21 @@ async function delay(ms) {
97
100
### `sendNoContent(event, code?)`
98
101
99
102
Respond with an empty payload.<br>
103
+
100
104
Note that calling this function will close the connection and no other data can be sent to the client afterwards.
101
105
102
106
### `sendRedirect(event, location, code)`
103
107
104
108
Send a redirect response to the client.
109
+
105
110
It adds the `location` header to the response and sets the status code to 302 by default.
111
+
106
112
In the body, it sends a simple HTML page with a meta refresh tag to redirect the client in case the headers are ignored.
107
113
108
114
### `sendStream(event, stream)`
109
115
110
116
Send a stream response to the client.
117
+
111
118
Note: You can directly `return` a stream value inside event handlers alternatively which is recommended.
0 commit comments