Home node.js: Async.parallel, callback is not a function
Reply: 0

node.js: Async.parallel, callback is not a function

user1147 Published in June 18, 2018, 1:06 pm

So I want to get the amount of viewers from each subforum. I wanted to do this by using async.parallel and then receiving the results at the end. The problem is that I want to call the same function 4 times (one time for each subforum) with a different argument. How do I do this? The way you see it below is how I tried to do it, but it gave me an error that 'callback is not a function'. Does anyone know how to properly do this?

Node.js code

router.get('/getSubViews', function(req, res) {

    getViewers('tips & tricks'),
], function(err, result) {
    if (err) {
        return res.status(500).json({
            message: "Something went wrong",
            err: err
        message: "Successfully retrieved the section",
        obj: 'whatever'

function getViewers(subForum, callback){

        SubViewCount.findOne({'section': subForum}, function(err, doc){
            callback(null, doc.views);
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.573084 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO