Skip to content

Commit ac644c4

Browse files
authored
fix(ngx-auth): Correctly implement the body parameter of POST, PUSH and PATCH
1 parent 9b1fb86 commit ac644c4

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

libs/angular/authentication/src/lib/services/authenticated-http-client/authenticated-http-client.service.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,59 +112,68 @@ export class NgxAuthenticatedHttpClient {
112112
* Constructs a POST request to the provided API
113113
*
114114
* @param url - The url of the API
115+
* @param body - The body we wish to send
115116
* @param params - An optional set of params we wish to send to the API
116117
* @param withCredentials - Whether the call is made by an authenticated user, by default true
117118
* @param context - An optional HTTPContext
118119
*/
119120
public post<DataType = void>(
120121
url: string,
122+
body: any,
121123
params?: Parameters<HttpClient['post']>[1]['params'],
122124
withCredentials: boolean = true,
123125
context?: HttpContext
124126
): Observable<DataType> {
125127
return this.httpClient.post<DataType>(
126128
this.handleUrl(url),
127-
clean({ params, withCredentials, context }) as Parameters<HttpClient['post']>[1]
129+
body,
130+
clean({ params, withCredentials, context }) as Parameters<HttpClient['post']>[2]
128131
);
129132
}
130133

131134
/**
132135
* Constructs a PUT request to the provided API
133136
*
134137
* @param url - The url of the API
138+
* @param body - The body we wish to send
135139
* @param params - An optional set of params we wish to send to the API
136140
* @param withCredentials - Whether the call is made by an authenticated user, by default true
137141
* @param context - An optional HTTPContext
138142
*/
139143
public put<DataType = void>(
140144
url: string,
145+
body?: any,
141146
params?: Parameters<HttpClient['put']>[1]['params'],
142147
withCredentials: boolean = true,
143148
context?: HttpContext
144149
): Observable<DataType> {
145150
return this.httpClient.put<DataType>(
146151
this.handleUrl(url),
147-
clean({ params, withCredentials, context }) as Parameters<HttpClient['put']>[1]
152+
body,
153+
clean({ params, withCredentials, context }) as Parameters<HttpClient['put']>[2]
148154
);
149155
}
150156

151157
/**
152158
* Constructs a PATCH request to the provided API
153159
*
154160
* @param url - The url of the API
161+
* @param body - The body we wish to send
155162
* @param params - An optional set of params we wish to send to the API
156163
* @param withCredentials - Whether the call is made by an authenticated user, by default true
157164
* @param context - An optional HTTPContext
158165
*/
159166
public patch<DataType = void>(
160167
url: string,
168+
body: any,
161169
params?: Parameters<HttpClient['patch']>[1]['params'],
162170
withCredentials: boolean = true,
163171
context?: HttpContext
164172
): Observable<DataType> {
165173
return this.httpClient.patch<DataType>(
166174
this.handleUrl(url),
167-
clean({ params, withCredentials, context }) as Parameters<HttpClient['patch']>[1]
175+
body,
176+
clean({ params, withCredentials, context }) as Parameters<HttpClient['patch']>[2]
168177
);
169178
}
170179
}

0 commit comments

Comments
 (0)