Skip to content

Commit e50f588

Browse files
committed
fix: Camelcasing broke the body params
1 parent 4307e76 commit e50f588

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

src/infrastructure/RequestHelper.js

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,26 +121,39 @@ class RequestHelper {
121121
}
122122

123123
static async request(type, service, endpoint, options = {}, form = false, stream = false) {
124-
const requestOptions = defaultRequest(service, endpoint, {
125-
headers: service.headers,
126-
});
127-
128124
try {
129125
switch (type) {
130126
case 'get':
131127
if (stream) return await getStream(service, endpoint, options);
132128
return await getPaginated(service, endpoint, options);
129+
133130
case 'post': {
134-
const body = form ? 'formData' : 'body';
135-
requestOptions[body] = options;
131+
const requestOptions = defaultRequest(service, endpoint, {
132+
headers: service.headers,
133+
[form ? 'formData' : 'body']: options,
134+
});
135+
136136
return await service.requester.post(requestOptions);
137137
}
138-
case 'put':
139-
requestOptions.body = options;
138+
139+
case 'put': {
140+
const requestOptions = defaultRequest(service, endpoint, {
141+
headers: service.headers,
142+
body: options,
143+
});
144+
140145
return await service.requester.put(requestOptions);
141-
case 'delete':
142-
requestOptions.qs = options;
146+
}
147+
148+
case 'delete': {
149+
const requestOptions = defaultRequest(service, endpoint, {
150+
headers: service.headers,
151+
qs: options,
152+
});
153+
143154
return await service.requester.delete(requestOptions);
155+
}
156+
144157
default:
145158
throw new Error(`Unknown request type ${type}`);
146159
}

0 commit comments

Comments
 (0)