Sunday, 12 March 2017

Promise.all(...).spread is not a function when running promises in parallel

I'm trying to run 2 promises in paralel with sequelize, and then render the results in a .ejs template, but I'm receiving this error:

 Promise.all(...).spread is not a function

This is my code:

var environment_hash = req.session.passport.user.environment_hash;
var Template  = require('../models/index').Template;
var List      = require('../models/index').List;

var values = { 
    where: { environment_hash: environment_hash,
             is_deleted: 0 
        }                    
};

template = Template.findAll(values);
list = List.findAll(values);


Promise.all([template,list]).spread(function(templates,lists) {

    res.render('campaign/create.ejs', {
        templates: templates,
        lists: lists
    });

});

How can I solve thhis?



via Filipe Ferminiano

No comments:

Post a Comment