Monday, 12 June 2017

Node js: says "no table exists" in browser but table does exist in terminal?

I am new to Node JS here and I am trying to follow heroku's tutorial to provision a PostGres Database. I have no idea what I am doing wrong.

This is how Im trying to display my data:

 pg.connect(procStr, function(err, client, done) {
      //console.log(client);

    client.query('SELECT * FROM table1', function(err, result) {
      done();
      if (err)
       { console.error(err); response.send("Error happened " + err); }
      else
       { response.render('/pages/db', {results: result.rows} ); }
    });
  });

});

I created the table exactly as described and in terminal everything is there:

enter image description here

But in browser I get "Error happened error: relation "table1" does not exist"

Only when I go to /db of course. What am I doing wrong?



via skyguy

No comments:

Post a Comment