formacao
This commit is contained in:
+16
-1
@@ -83,7 +83,7 @@ var HonoRequest = class {
|
||||
return headerData;
|
||||
}
|
||||
async parseBody(options) {
|
||||
return this.bodyCache.parsedBody ??= await parseBody(this, options);
|
||||
return parseBody(this, options);
|
||||
}
|
||||
#cachedBody = (key) => {
|
||||
const { bodyCache, raw } = this;
|
||||
@@ -147,6 +147,21 @@ var HonoRequest = class {
|
||||
arrayBuffer() {
|
||||
return this.#cachedBody("arrayBuffer");
|
||||
}
|
||||
/**
|
||||
* `.bytes()` parses the request body as a `Uint8Array`.
|
||||
*
|
||||
* @see {@link https://hono.dev/docs/api/request#bytes}
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* app.post('/entry', async (c) => {
|
||||
* const body = await c.req.bytes()
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
bytes() {
|
||||
return this.#cachedBody("arrayBuffer").then((buffer) => new Uint8Array(buffer));
|
||||
}
|
||||
/**
|
||||
* Parses the request body as a `Blob`.
|
||||
* @example
|
||||
|
||||
Reference in New Issue
Block a user