Why does Node.js Postgres Wiki example insert multiple records per http request?

Viewed 139

We are using the node-postgres (pg on NPM) for our app but were having issues so we decided to go back to the examples on the Wiki:

https://github.com/brianc/node-postgres/wiki/Example

When we run the example, each http request inserts two records into the Postgres ("visit") table. Is this the desired behaviour...?

We published the example code to Heroku: https://node-postgres-example.herokuapp.com
(Note: Visit using Google Chrome)

Note: we made 3 changes to the server.js code from the Wiki to make it run on Heroku this is on GitHub: https://github.com/dwyl/postgres-connection-pool-test

(the changes we made to server.js are purely to (1) create the visit table if it does not already exist, (2) to get the postgres connection string from process.env.DATABSE_URL and (3) to listen on process.env.PORT on Heroku. all the rest of the code is as per the Wiki example)

2 Answers
Related