Answer the question
In order to leave comments, you need to log in
How to interact with data from the database in JS?
The bottom line is that when working with Google Maps api, I need to display data that is taken from the database in the information field on the page when clicking on a marker, each marker has its own information. I take the data with a request (its code is below) in a separate file. How to enter data from the database (so that I can put it in my main js file into an array and then process and display it) into my main js file that connects and displays the map and markers on it.
If it is possible, please tell me how, preferably a simpler way =)
const {Client} = require('pg')
const connectionString = 'postgressql://postgres:[email protected]:5432/Data'
const client = new Client({
connectionString:connectionString,
})
client.connect()
client.query('select train_table, stop_number, average_count_passenger from averagecountpassenger where train_table in (3,4,9)', (err, res) =>{
console.log(err)
console.log(res)
client.end()
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question