number is not a function in async
-
I need to get id from user by an username so I do this:
user.getUidByEmail(username,function(err,id){ if(err){ return next(err); } next(null,parseInt(id)); }); ``` I Obtain this exception: number is not a function. ``` TypeError: number is not a function at /vagrant/nodebb/node_modules/nodebb-plugin-connect-delete-account/lib/sockets.js:75:5 at /vagrant/nodebb/src/database/mongo/sorted.js:325:4 at handleCallback (/vagrant/nodebb/node_modules/mongodb/lib/utils.js:96:12) at /vagrant/nodebb/node_modules/mongodb/lib/collection.js:1357:5 at handleCallback (/vagrant/nodebb/node_modules/mongodb/lib/utils.js:96:12) at /vagrant/nodebb/node_modules/mongodb/lib/cursor.js:661:5 at handleCallback (/vagrant/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:159:5) at setCursorNotified (/vagrant/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:511:3) at /vagrant/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:582:16 at queryCallback (/vagrant/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:241:5) at Callbacks.emit (/vagrant/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:119:3) at null.messageHandler (/vagrant/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:358:23) at Socket.<anonymous> (/vagrant/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js:292:22) at Socket.emit (events.js:95:17) at Socket.<anonymous> (_stream_readable.js:765:14) at Socket.emit (events.js:92:17) TypeError: number is not a function at /vagrant/nodebb/node_modules/nodebb-plugin-connect-delete-account/lib/sockets.js:75:5 at /vagrant/nodebb/src/database/mongo/sorted.js:325:4 at handleCallback (/vagrant/nodebb/node_modules/mongodb/lib/utils.js:96:12) at /vagrant/nodebb/node_modules/mongodb/lib/collection.js:1357:5 at handleCallback (/vagrant/nodebb/node_modules/mongodb/lib/utils.js:96:12) at /vagrant/nodebb/node_modules/mongodb/lib/cursor.js:661:5 at handleCallback (/vagrant/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:159:5) at setCursorNotified (/vagrant/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:511:3) at /vagrant/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:582:16 at queryCallback (/vagrant/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:241:5) at Callbacks.emit (/vagrant/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:119:3) at null.messageHandler (/vagrant/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:358:23) at Socket.<anonymous> (/vagrant/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js:292:22) at Socket.emit (events.js:95:17) at Socket.<anonymous> (_stream_readable.js:765:14) at Socket.emit (events.js:92:17)
Anyone can help me?
}, -
@baris I need to ask a think. I change username of a user that has like username "lupo". I change in another username "username_deleted". But when I log in with username "lupo" and password the login works and open the profile "username_deleteted". So it seems that I can access with the old username and with the new. How is it possibile this? I need to change finally the username. can you say me any method that I can use to do this?
-
@baris thanks it works. I wrong because I used:
user.setUserField
and not user.updateProfile. But there is another question if I do this
var id=30; var username_mod='usernameDelete' + 40; user.updateProfile(id, {username: username_mod}, next);
I Obtain:
TypeError: params.message.trim is not a function
the line is 28892 and it is:
params.message = params.message ? params.message.trim() : '';
How is it possible this?