Skip to content

Commit

Permalink
update eventToRequest util
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jul 10, 2023
1 parent 4baf4c0 commit 5be88e0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/utils/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,18 @@ export function getRequestURL(
* @returns {Request}
*
* ```ts
* const eventHandler = event => {
* const eventHandler = defineEventHandler(event => {
* const request = await eventToRequest(event)
* if(request instanceof Request) // true
* }
* })
* ```
*/
export async function eventToRequest(event: H3Event) {
const url = new URL(getRequestURL(event));
const url = getRequestURL(event);
const body = await readRawBody(event);

return new Request(url, {
headers: getRequestHeaders(event) as HeadersInit,
method: getMethod(event),
method: event.method,
headers: event.headers,
body,
});
}

0 comments on commit 5be88e0

Please sign in to comment.