Skip to content

Commit

Permalink
fix(useBody): support req._body
Browse files Browse the repository at this point in the history
workaround for unjs/unenv#8
  • Loading branch information
pi0 committed Nov 24, 2021
1 parent 34ae7c8 commit 0d0cd61
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/utils/body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ export function useRawBody (req: IncomingMessage, encoding: Encoding = 'utf-8'):
return Promise.resolve(encoding ? req[RawBodySymbol].toString(encoding) : req[RawBodySymbol])
}

// @ts-ignore
// Workaround for unenv issue https://github.com/unjs/unenv/issues/8
if (req._body) {
// @ts-ignore
return Promise.resolve(req._body)
}

return new Promise<string>((resolve, reject) => {
const bodyData: any[] = []
req
Expand Down

0 comments on commit 0d0cd61

Please sign in to comment.