Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //geography data
- router.get('/crimes', function (req, res) {
- var client = new pg.Client(conString);
- client.connect();
- var query = client.query(geo_query);
- query.on("row", function (row, result) {
- result.addRow(row);
- });
- query.on("end", function (result) {
- res.send(result.rows[0].row_to_json);
- res.end();
- });
- });
- router.post('/crimes', function (req, res) {
- var client = new pg.Client(conString);
- client.connect();
- const { enteredcrime_type, enteredstreet, lon, lat } = req.body;
- const crime_type = enteredcrime_type;
- const street = enteredstreet;
- var query = client.query(insert_lonlat, [crime_type, street, lon, lat], error => {
- if (error) {
- throw error
- } else {
- //runs the update of the where_is col
- client.query(geo_update);
- res.status(201).json({ status: 'success', message: 'Crime Data added.' });
- }
- })
- console.log(req.body);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement