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 8715835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:56:28+00:00 2026-06-13T05:56:28+00:00

High Level Overview: I have a nodejs expressjs server that makes use of the

  • 0

High Level Overview:

I have a nodejs expressjs server that makes use of the PostgreSQL nodejs driver called pg. I have a html file served to the client browser that when you click a button invokes a expressjs route on my expressjs server. This route will select data out of a PostgreSQL database and return it to the client html file. The problem is the route emits a response for every row selected in the query to the database. All the client (html browser) gets is the first row. I can write to the nodejs console server side and get all the rows to be displayed, but obviously that does me know good on my webpage.

Question:
How do I get my client html file to write to console on the client for every row emitted out of my expressjs route /pg? My assumption was on the client that the onSuccess would be fired for every row emitted out of my expressJS route.

NodeJS\ExpressJS Server File:

var express = require('express');
var pg = require('pg');

var app = express();

var MemoryStore = express.session.MemoryStore;

var conString = "postgres://joe_user:password@localhost/dev_db";

var client = new pg.Client(conString);
client.connect();



app.get('/home', function(req,res){
 res.sendfile(__dirname + '/views/index.html');
});
app.use(express.bodyParser());
app.use(express.cookieParser());
app.use
(
express.session
(
{ 
    key: 'some-key',
    secret: 'some-We1rD sEEEEEcret!',
    cookie: { secure: true },
    store: new MemoryStore({ reapInterval: 60000 * 10 }) 
}
)
);



app.use
(
function(err, req, res, next)
{
  // logic
  console.error(err.stack);
  res.send(500, 'Something broke!');
}
);

app.get('/pg', function(req, res)
{


   var  query = client.query("SELECT * FROM junk_data;"); //Returns 7000 rows with 8 columns total


query.on('row', function(row) 
{
   res.send(row);
   console.log(row);
}

);



}

);

process.on('uncaughtException', function (err) {
    console.log(err);
});

app.listen(4000);

HTML File:

<!DOCTYPE HTML>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Demo: dojo/request/xhr</title>
        <!--<link rel="stylesheet" href="style.css" media="screen">-->
        <!--<link rel="stylesheet" href="../../../resources/style/demo.css" media="screen">-->
    </head>
    <body>
        <h1>Demo: dojo/request/xhr</h1>
        <p>Click the button below to see dojo/request/xhr in action.</p>
        <div>

            <button id="textButton2" onclick="SubmitPGRequest();">Call Express Route For PostgreSQL</button>
            <!--<input type="button" value="Submit" onclick="SubmitRequest();"/> -->
        </div>
        <br /><br />
        <div id="resultDiv">
        </div>
        <!-- load dojo and provide config via data attribute -->
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/prototype/1.7/prototype.js"></script>
        <script>

function SubmitPGRequest()
{
            new Ajax.Request( '/pg', {
              method:  'get',
              onSuccess:  function(response){
                <!--alert(response.responseText); -->
                if(response.done) {
                alert('Done!');
                }else {
                console.log(response.responseText);}
              },
              onFailure:  function(){
                alert('ERROR');
              }
});
}
        </script>
    <

/body>

  • 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-06-13T05:56:29+00:00Added an answer on June 13, 2026 at 5:56 am

    Ok so I figured out an answer to my question.

    With the nodejs pg driver you can just send all the rows in the result object once the query has completed(end) and send them in one go. Below is what I ended up having in my expressjs server route to send all rows back the client.

    //fired once the function above has completed firing.    
    query.on('end',(result) 
    {
        res.send(result.rows);//send all rows back to client.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Most high-level languages (Python, Ruby, even Java) use pass-by reference. Obviously, we don't have
What is the high level overview of everyday TortoiseSVN usage. For example, I have
High level I have two tables that need to have some of the data
I have a high-level goal of creating a static utility class that encapsulates the
I've got the following code below. High level overview is that it is a
High Level With StructureMap, Can I define a assembly scan rule that for an
Are there any high-level, cross-platform, and abstracted (simple to use) widget toolkits for C
I find that many high level functions are missing in most well-known javascript libraries
Are there any high level language that don't support using C++ libraries?
This is for some high level Web/Rest tests of my whole system that are

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.