Skip to content

Commit 71f6e4b

Browse files
fix(opapi): ensure we never send a body with GET requests (#545)
1 parent 00d18a0 commit 71f6e4b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

opapi/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bpinternal/opapi",
3-
"version": "0.12.0",
3+
"version": "0.12.1",
44
"description": "",
55
"main": "./dist/index.js",
66
"module": "./dist/index.mjs",

opapi/src/generators/client-node.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export type ParsedRequest = {
8787
const isDefined = <T>(pair: [string, T | undefined]): pair is [string, T] => pair[1] !== undefined
8888
8989
export const toAxiosRequest = (req: ParsedRequest): AxiosRequestConfig => {
90-
const { method, path, query, headers: headerParams, body: data } = req
90+
const { method, path, query, headers: headerParams, body } = req
9191
9292
// prepare headers
9393
const headerEntries: [string, string][] = Object.entries(headerParams).filter(isDefined)
@@ -97,6 +97,10 @@ export const toAxiosRequest = (req: ParsedRequest): AxiosRequestConfig => {
9797
const queryString = qs.stringify(query, { encode: true, arrayFormat: 'repeat', allowDots: true })
9898
9999
const url = queryString ? [path, queryString].join('?') : path
100+
const data =
101+
['put', 'post', 'delete', 'patch'].includes(method.toLowerCase())
102+
? body
103+
: undefined
100104
101105
return {
102106
method,

0 commit comments

Comments
 (0)