Vonage / vonage-node-sdk

Vonage API client for Node.js. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
Apache License 2.0
375 stars 178 forks source link

[Bug]: getOwnedNumbers seems to return string (JSON) and not an object #903

Closed rrnara closed 5 months ago

rrnara commented 5 months ago

Node Version

18.x

Platform

Mac (Apple Silcon)

SDK Version

3.12.1

Code Sample

const auth = new Auth({ apiKey: process.env.VONAGE_API_KEY, apiSecret: process.env.VONAGE_API_SECRET }) const vonage = new Vonage(auth) const numbersResp = await vonage.numbers.getOwnedNumbers() console.log('type', typeof numbersResp)

Expected Behavior

type is object

Actual Behavior

type is string

imaustink commented 5 months ago

I started seeing this today as well. Yesterday evening it was working fine for me and my team.

It looks like a small change was made to the Phone Numbers APIs and they now return Content-Type: application/json;charset=UTF-8 and the SDK is explicitly expecting application/json: https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/server-client/lib/client.ts#L379

manchuck commented 5 months ago

Yea I can confim that is what is happening. The charset is throwing off that switch statement. Working on a fix now

manchuck commented 5 months ago

The fix has been released in version 3.12.2 (1.10.2 of the @vonage/server-client and @vonage/numbers)