Skip to content

Commit

Permalink
fix: send form request sending undefined for body
Browse files Browse the repository at this point in the history
  • Loading branch information
manchuck committed Nov 8, 2024
1 parent 0be564e commit 34e0ea6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions packages/numbers/lib/numbers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export class Numbers extends Client {
* @param {NumbersSearchFilter} filter - The filter criteria for searching available numbers.
* @return {Promise<NumbersAvailableList>} A promise that resolves to a list of available phone numbers or an error response.
*
* @example
* @example
* Search for available numbers that can send SMS and make voice calls
* ```ts
* import { Country, Feature } from '@vonage/numbers';
Expand Down Expand Up @@ -306,8 +306,14 @@ export class Numbers extends Client {
const resp = await this.sendFormSubmitRequest<NumbersEmptyResponse>(
`${this.config.restHost}/number/update`,
{
country: params.country,
msisdn: params.msisdn,
...(appId ? { app_id: appId } : {}),
...params,
moHttpUrl: params.moHttpUrl,
moSmppSysType: params.moSmppSysType,
voiceCallbackType: params.voiceCallbackType,
voiceCallbackValue: params.voiceCallbackValue,
voiceStatusCallback: params.voiceStatusCallback,
},
);

Expand Down
4 changes: 2 additions & 2 deletions packages/server-client/lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,14 @@ export class Client {
*/
async sendFormSubmitRequest<T>(
url: string,
payload?: Record<string, string>,
payload?: Record<string, string | undefined>,
): Promise<VetchResponse<T>> {
const request = {
url,
method: HTTPMethods.POST,
type: ContentType.FORM_URLENCODED,
headers: { Accept: 'application/json' },
...(payload ? { data: payload } : {}),
...JSON.parse(JSON.stringify((payload ? { data: payload } : {}))),
} as VetchOptions;

return await this.sendRequest<T>(request);
Expand Down

0 comments on commit 34e0ea6

Please sign in to comment.