Vonage / vonage-node-code-snippets

NodeJS code examples for using Vonage
MIT License
67 stars 78 forks source link

verify.start not fund #121

Closed GadeBao closed 1 year ago

GadeBao commented 1 year ago

Hi Team,

This code seems does not work - it returns **undefined** error indicating that the method signature is unmatching.

vonage.verify.start({ number: RECIPIENT_NUMBER, senderId: BRAND_NAME })

biligeny commented 1 year ago

Any update on this, please?

dragonmantank commented 1 year ago

'vonage.verify.start()' is a new method in v3. Can you let us know what version of the SDK you currently have installed?

biligeny commented 1 year ago

Hi,

I am using this version.

"dependencies": { "@vonage/server-sdk": "^3.0.9", "express": "^4.18.2", "uuid": "^8.3.2" }, "devDependencies": { "nodemon": "^2.0.20" }

スクリーンショット 2022-11-26 午前10 52 05
biligeny commented 1 year ago

Hi dragonmantank

I also cloned the repository and ran following but got the same error.

Thanks

dragonmantank commented 1 year ago

I just corrected an argument typo in the code snippet, can you re-pull this repository and try again? If you ran the snippet it should have just printed 'undefined' and not sent the code, this fix corrects that.

that was a different issue than what you are experiencing though. On your express install, and your code snippet install, can you see if there is anything in node_modules/@vonage/verify/dist ? Though if all that code is missing you shouldn't even be able to create a Vonage object, as Verify is a required component.

Can you also verify in your express app that the context object has a proper Vonage object? That looks like custom code, so if that isn't set properly .verify won't be available either.

GadeBao commented 1 year ago

Hi,

The request.js is working now after you corrected the signature.

The context is just a wrapper of Vonage as a singleton, and it works as check.js is not issue.

Apart from it and regarding dist, please find below. image

I wonder if SDK V.3 relies on node version like v.16 or v.18?

Thanks,

dragonmantank commented 1 year ago

We require at least Node v14 now, where the older SDKs supported back to something like v8 or v10.

Going back and reading, I know what the issue was and the mix-up was.

The sample script returned undefined not because of an issue with the SDK, but an issue with the response data. The code snippet was setting senderId and not brandId, so the API returned an error. The code snippet was not doing any error handling, so assumed that all responses were valid calls - in this case, we returned an error. The undefined response was because it assumed the response from the API contained a request_id property. Since it was an error, that property did not exist, so it returned undefined.

So the SDK itself was fine, just the code snippet had a small bug.

Let me know if you have any more issues!