Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7689331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:08:29+00:00 2026-05-31T20:08:29+00:00

When the following route is called in express, it is actually executed 6 times.

  • 0

When the following route is called in express, it is actually executed 6 times. The console.log is printed 6 times, and my mongoose logic is executed 6 times (saves 6 time in database).

I then get returned a http 500 from cloud9ide “Could not proxy request”. I am really confused, I have no loops in my code, how can this happen? The console.log(“in else (2)”); get printed 6 times.

Edit: I have tried the mongooseLogic code with various parts commented out, and the issue was still there. This looks like it isn’t a mongoose issue.

Second edit: I have changed the post for get and hardcoded the body that would be sent, and the route was executed only once.

Third edit: I am also using everyauth for session/authentication with the facebook oauth.

app.post("/result/:userId/:elementId", function(req, res) {
  var receivedJSON = req.body;    

  console.log("In route");

  //Making sure the receive request is valid
  if(typeof(receivedJSON.type) !== undefined) {
    mongooseLogic.saveResults(req.params.elementId, receivedJSON, req.params.userId, function(message) {
      if(message === "Success") {
        res.json({ success: true,  message: 'Result saved.'});    
      }
      else {
        res.json({ success: false,  message: 'Error in saving results. Trace: ' + message});
      }
    });
  }
  else {
    res.json({ success: false,  message: 'Failed, Invalid object sent to server'});   
  }
});

Code on the mongooseLogic file:

var saveResults = function(elementRefId, receivedResult, userId, callback){

    if(elementRefId.toString().length !== 24 ){
       callback("Invalid objectId for elementId");
    }
    else{
            Result.findOne({ "id" : userId, "serieResult.id": elementRefId }, function(err, result){
                if(err){
                    callback("No Document found: " + err);
                }
                else if( result === null){
                    console.log("in null");
                    var tempResult =  {
                        id           : elementRefId, 
                        unit         : receivedResult.unit, 
                        value        : receivedResult.value 
                    }
                    Result.update({ "id" : userId}, { $push: {"serieResult": tempResult}}, {upsert: true}, function(err){
                        if(err){
                            callback("Error in saving result (Distance): " + err);
                        }
                        else{
                            callback("Success");
                        }
                    });
                }
                else{            
                    Result.update({ "id" : userId, "serieResult.id": elementRefId },
                        { $set:{
                            "serieResult.$.unit"        : receivedResult.unit,
                            "serieResult.$.value"       : receivedResult.value,
                        },{upsert: true}, function(err){
                            if(err){
                                callback("Cant update doc: " + err);
                            }
                            else{
                                console.log("in else (2)");
                                 callback("Success");
                            }
                    }); 
                }
            }); 
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T20:08:30+00:00Added an answer on May 31, 2026 at 8:08 pm

    This was a problem with the Cloud9 proxy that interfered. The problem was adressed thanks to this issue and has been resolved.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following partial. It can be called from three different times in
I have the following route defined routes.MapRoute( ItemName, {controller}/{action}/{projectName}/{name}, new { controller = Home,
I have the following route: {language}/{controller}.mvc/{action}/{id} Once a user has choosen the language it
I have the following route: routes.MapRoute( Default, // Route name {controller}/{action}/{id}, // URL with
I've defined the following route for a simple blog. routes.MapRoute( Blog, blog/{year}/{month}/{day}, new {
I cannot get the following route to fire when a url is requested from
I have the following route's defined: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute({resource}.axd/{*pathInfo}); routes.MapRoute(
Suppose the following route: {region}/{storehouse}/{controller}/{action} These two parameters region and storehouse altogether identify a
I've got the following url route and i'm wanting to make sure that a
I have a route like following, ideally I would like it to match: domain.com/layout/1-slug-is-the-name-of-the-page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.