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
382 stars 181 forks source link

Nexmo SMS or Verification sent but error thrown afterwards #192

Closed ghost closed 6 years ago

ghost commented 6 years ago

error: problem with API request detailed stacktrace below error: undefined C:\abc\ghi\node_modules\nexmo\lib\index.js:135 if (!err && apiResponse.status && apiResponse.messages[0].status > 0) { TypeError: Cannot read property 'status' of undefined

code: var nexmo = new Nexmo({ apiKey: 'xxxxx', apiSecret: 'xxxxxxxx' }, {debug:true}); router.post('/', function(req, res, next){ let phone = req.body.phone; let message = req.body.message; nexmo.message.sendSms( xxxxx, phone, message, {type: 'unicode'}, (err) => {if (responseData) {console.log(responseData)}} ); });

AlexLakatos commented 6 years ago

Hi @briansimiyu , what's the package version for Nexmo you're using?

6illes commented 6 years ago

Same problem, using node v10.5.0, nvm v0.33.11, npm v6.1.0 nexmo lib package.json { "_from": "nexmo", "_id": "nexmo@2.2.1", "_inBundle": false, "_integrity": "sha512-Gr6uSxvVVMJy3gJE/HznkgkxbstwOZbG03t6Ln8ehcgNkY2GrU0vsP4ZdadGuxfgTJ3oZHvijXAYBpb3d2W3XA==", "_location": "/nexmo", "_phantomChildren": {}, "_requested": { "type": "tag", "registry": true, "raw": "nexmo", "name": "nexmo", "escapedName": "nexmo", "rawSpec": "", "saveSpec": null, "fetchSpec": "latest" }, "_requiredBy": [ "#USER", "/" ], "_resolved": "https://registry.npmjs.org/nexmo/-/nexmo-2.2.1.tgz", "_shasum": "cbea43697f30af51a895db34ae90f1e0e1291f28", "_spec": "nexmo", "_where": "/opt/alerter", "author": { "name": "nexmo" }, "bugs": { "url": "https://github.com/nexmo/nexmo-node/issues" }, "bundleDependencies": false, "contributors": [ { "name": "nexmo" }, { "name": "pvela" }, { "name": "leggetter" }, { "name": "akuzi" }, { "name": "bpilot" }, { "name": "justinfreitag" }, { "name": "ecwyne" }, { "name": "https://github.com/backhand" } ], "dependencies": { "jsonwebtoken": "^8.2.1", "request": "^2.83.0", "uuid": "^2.0.2" }, "deprecated": false, "description": "Nexmo REST API client for Node.js. API support for SMS, Voice Calls, Text-to-Speech, Numbers, Verify (2FA) and more.", "devDependencies": { "babel-cli": "^6.7.7", "babel-plugin-add-module-exports": "^0.2.1", "babel-plugin-istanbul": "^4.1.6", "babel-preset-es2015": "^6.9.0", "babel-register": "^6.7.2", "bluebird": "^3.4.6", "body-parser": "^1.15.2", "chai": "^3.5.0", "cross-env": "^5.1.1", "dotenv": "^2.0.0", "eslint": "^3.18", "eslint-config-prettier": "^2.9.0", "eslint-plugin-prettier": "^2.3.1", "expect.js": "^0.3.1", "express": "^4.14.0", "mocha": "^3.2.0", "ngrok": "^2.2.2", "nodemon": "^1.17.3", "nyc": "^11.7.1", "prettier": "^1.12.1", "sinon": "^1.17.4", "sinon-chai": "^2.8.0", "sinon-expect": "^0.3.0" }, "homepage": "https://github.com/nexmo/nexmo-node", "keywords": [ "sms", "voice", "nexmo", "verify", "2fa", "phone numbers" ], "license": "MIT", "main": "lib/Nexmo", "name": "nexmo", "repository": { "type": "git", "url": "git://github.com/nexmo/nexmo-node.git" }, "scripts": { "compile": "babel -d lib src/ -s inline", "lint": "eslint src test", "lint-fix": "eslint --fix src test", "prepublish": "npm run compile", "pretest": "npm run lint", "test": "npm run test-no-lint", "test-coverage": "cross-env NODE_ENV=test nyc mocha", "test-coverage-html": "cross-env NODE_ENV=test nyc --reporter html mocha", "test-no-lint": "npm run compile && mocha --compilers ./node_modules/.bin/_mocha --compilers js:babel-register ./test/*- test.js", "test-watch": "nodemon --watch src --watch test -x 'npm run test-no-lint'" }, "version": "2.2.1" }

AlexLakatos commented 6 years ago

There was a breaking change in node 10.2.0 in how they handle request.on('close') that made all callbacks to be called a second time with an empty error. That's been fixed in the nexmo package version 2.3.2, so please update to the latest version of nexmo by running npm i nexmo --save

ghost commented 6 years ago

Thanks, v-2.3.2 has solved the problem

6illes commented 6 years ago

Thank you for your commitment

Le lun. 25 juin 2018 à 05:10, Alex Lakatos notifications@github.com a écrit :

There was a breaking change in node 10.2.0 in how they handle request.on('close') that made all callbacks to be called a second time with an empty error. That's been fixed in the nexmo package version 2.3.2, so please update to the latest version of nexmo by running npm i nexmo --save

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Nexmo/nexmo-node/issues/192#issuecomment-399818415, or mute the thread https://github.com/notifications/unsubscribe-auth/ABXJ_tYnUwafGDnpHjoTo_gpwFMOpcgVks5uAFSxgaJpZM4Uzase .