Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callback is not a function #2043

Closed
mmahmood opened this issue Jun 12, 2016 · 1 comment
Closed

Callback is not a function #2043

mmahmood opened this issue Jun 12, 2016 · 1 comment
Labels
type:question Support or code-level question

Comments

@mmahmood
Copy link

Issue Description

I am trying to get a list of AccessTokens, and using these to get a list of Twitter followers who are also my app users. But I keep getting this error "verbose: error: MongoError: TypeError: callback is not a function". What am I doing wrong?

Copying the code:
return accessTokenQuery.find({ useMasterKey: true })
.then(function(targetAccessTokens){
if(targetAccessTokens==undefined){
return Parse.Promise.as();
}
var twitterIds = "";
var addComma = false;
var idMap = [];
for(var i=0; i< targetAccessTokens.length; i++){
twitterIds += (addComma? ",": "") + targetAccessTokens[i].get("twitterId");
idMap[targetAccessTokens[i].get("twitterId")] = targetAccessTokens[i];
addComma = true;
}
return postsJS.getTwitterUserFriendsLookupPromise(twitterIds, config, sourceAccessToken, twitterSecretKey)
.then(function(response){
if(response==undefined || response.data==undefined){
return Parse.Promise.error(response);
}

        for(var i=0; i<response.data.length; i++){
            var relationship = response.data[i];
            var targetAccessToken = idMap[relationship.id_str];
            if(targetAccessToken != undefined && relationship.connections!=undefined 
                && relationship.connections.indexOf("followed_by")> -1){                    
                relation.add(targetAccessToken.get("createdFor"));
            }
        }
        userDetails.set("friendsLastUpdatedAt", new Date());
        userDetails.set("isTriggerUpdate", true);
        return userDetails.save(null, { useMasterKey: true})
        .then(function(){
            return Parse.Promise.as();
        }, function(error){
            winstonJS.logger.error("Error (Suppressed) saving friend details for userDetails" + userDetails.id + ". Error " + JSON.stringify(error, null, 4));
            return Parse.Promise.as("Error (Suppressed) saving user details for " + userDetails.id);        
        });

    }, function(error){
        winstonJS.logger.error("Error (suppressed) processing twitter users " + sourceAccessToken.id + " and " + twitterIds 
            +".  Error " + JSON.stringify(error, null, 4));
        return Parse.Promise.as("Error (suppressed) processing twitter users " + sourceAccessToken.id + " and " + twitterIds);      
    });
})
.then(function(){
    return Parse.Promise.as();
}, function(error){
    winstonJS.logger.error("Error processing twitter users " + sourceAccessToken.id + ".  Error " + JSON.stringify(error, null, 4));
    return Parse.Promise.error("Processing twitter users " + sourceAccessToken.id);     
});

Logs/Trace

verbose: GET /parse/classes/UserAccessToken { 'user-agent': 'node-XMLHttpRequest, Parse/js1.8.5 (NodeJS 4.3.0)',
accept: '/',
'content-type': 'text/plain',
host: 'localhost:1337',
'content-length': '442',
connection: 'close' } {
"where": {
"createdFor": {
"$inQuery": {
"where": {
"status": {
"$in": [
"Active",
"Inactive"
]
}
},
"className": "_User"
}
},
"activeSocialLink": 3,
"objectId": {
"$ne": "bohjnw1kkj"
}
},
"limit": 100
}
verbose: error: MongoError: TypeError: callback is not a function
at null.messageHandler (D:\Work\ConradLabs\Doofl\doofl-parseserver\node_modules\parse-server\node_modules\mongodb\node_modules\mongodb-core\lib\topologies\server.js:399:39)
at Socket. (D:\Work\ConradLabs\Doofl\doofl-parseserver\node_modules\parse-server\node_modules\mongodb\node_modules\mongodb-core\lib\connection\connection.js:302:22)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:146:16)
at Socket.Readable.push (_stream_readable.js:110:10)
at TCP.onread (net.js:523:20)
error: Uncaught internal server error. { [MongoError: TypeError: callback is not a function]
name: 'MongoError',
message: [TypeError: callback is not a function] } MongoError: TypeError: callback is not a function
at null.messageHandler (D:\Work\ConradLabs\Doofl\doofl-parseserver\node_modules\parse-server\node_modules\mongodb\node_modules\mongodb-core\lib\topologies\server.js:399:39)
at Socket. (D:\Work\ConradLabs\Doofl\doofl-parseserver\node_modules\parse-server\node_modules\mongodb\node_modules\mongodb-core\lib\connection\connection.js:302:22)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:146:16)
at Socket.Readable.push (_stream_readable.js:110:10)
at TCP.onread (net.js:523:20)

@hramos
Copy link
Contributor

hramos commented Jun 22, 2016

I am closing this out as we're trying to cut down on the number of non-issues. This will help us focus on the issues that are actively preventing people from migrating their production apps to Parse Server.

For code-level and/or implementation-related questions or technical support, please refer to Stack Overflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question Support or code-level question
Projects
None yet
Development

No branches or pull requests

3 participants