How to increase gateway time-out of angularJs $http request application hosted on Elastic BeanStalk with node.js as back-end

I am working on MeanStack Project Using AngularJs as my front-end I am facing an issue of connection timeout while sending email to all user by using nodemailer. as I am sending email to multiple users it is obvious that it will take some time. due to which I am getting an error 504 Gateway Timeout. and it is well understood that I am getting this error message because I am not getting the response in IDle time. so I have tried to increase IDle timeout from AWS Load Balancer which does not help me. can anyone suggest me the solution?

Here is my angular function which is sending and receiving the response here I had also tried Timeout function.

SendBulkemail: function(data){
        return $http({
            method: 'post',
            url: '/api/users/SendBulkemail',
            data: data,
            timeout: 10000  //it does not helped me.
        }).then(function(res) {
            return res.data;
        }).catch(function(err) {
            console.error('Internal Server error!!');
            console.error(err);
            return err;
        });
    }   

this is my node function by which i am sending email to all users.

apiRouter.post('/users/SendBulkemail', function(req, res) {
    User.find({
         role: {
             $ne: 'dummy'
         }
    }, function(err, users) {
        if (err) {
            console.log(err);
        } else {
            for (let index = 0; index < users.length; index++) {
                emailExistence.check(users[index].email, function(error, response) {
                    if (response == true) {
                        var mailOptions = {
                            from: "[email protected]",
                            to: users[index].email,
                            subject: req.body.subject,
                            html: req.body.msg
                        };
                        transporter.sendMail(mailOptions, function(err) {
                            if (err) {
                                console.log('Sending to ' + users[index].email + ' failed: ' + err);

                            } else {
                                console.log('Sent to ' + users[index].email);
                                if (index == users.length - 1) {
                                    return res.send({
                                        status: true,
                                        msg: "Email successfully sent to all users!!"
                                    });
                                }
                            }
                        });
                    }
                })
            }
        }
    })
})

can anyone suggest me how can I resolve this problem that it will send email to all user then after i will get a response of success or failure and in between my connection will not be interpreted like there should not be no Gateway Timeout?

Source: AngularJS