Skip to content

Commit

Permalink
chore(request): http verbs with body
Browse files Browse the repository at this point in the history
  • Loading branch information
enzonotario committed Feb 16, 2025
1 parent 8358f2a commit 121bc0e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/lib/codeSamples/convertOARequestToRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@ export function OARequestToRequest(oaRequest: OARequest): Request {
const query = new URLSearchParams(oaRequest.query).toString()

const headers = new Headers(oaRequest.headers)
const body = ['POST', 'PUT', 'PATCH'].includes(method) && oaRequest.body ? JSON.stringify(oaRequest.body) : undefined
const body = [
'POST',
'PUT',
'PATCH',
'DELETE',
'OPTIONS',
'TRACE',
].includes(method) && oaRequest.body
? JSON.stringify(oaRequest.body)
: undefined

if (body && !headers.has('content-type')) {
headers.set('content-type', 'application/json')
Expand Down

0 comments on commit 121bc0e

Please sign in to comment.