File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -128,9 +128,30 @@ export type FexiosFinalContext<T = any> = Omit<
128128 | 'responseType'
129129 | 'url'
130130 | 'query'
131+ | 'data'
131132> & {
132133 /** Response Headers */
133134 readonly headers : Headers
135+ /**
136+ * Resolved response body
137+ * @note
138+ * This is a read-only property,
139+ * if you want to completely replace the ctx.data,
140+ * you should return Response in `afterResponse` hook.
141+ * @example
142+ * ```
143+ * // DO THIS √
144+ * fx.on('afterResponse', (ctx) => {
145+ * return Response.json({ newData: 'new data' }, { status: 200 })
146+ * })
147+ * // DON'T DO THIS ×
148+ * fx.on('afterResponse', (ctx) => {
149+ * ctx.data = { newData: 'new data' } // error!
150+ * return ctx
151+ * })
152+ * ```
153+ */
154+ readonly data : T
134155 /**
135156 * Response type of data
136157 * If not set in request options, it will be guessed based on content-type header.
You can’t perform that action at this time.
0 commit comments