Skip to content

Instantly share code, notes, and snippets.

Created September 21, 2016 15:33
Show Gist options
  • Save anonymous/868447ebece55338b5cd3c3f68ee26d6 to your computer and use it in GitHub Desktop.
Save anonymous/868447ebece55338b5cd3c3f68ee26d6 to your computer and use it in GitHub Desktop.
app.get('/data', (request, res) => {
res.setHeader("Access-Control-Allow-Origin",'http://localhost:8080');
fetch(request, res, function(err, data){
console.log(data, "dickt")
if (err){
}else{
res.send(data);
}
});
});
var fetch = function(request, res, next){
var data = []
db.each('SELECT shape_pt_lat, shape_pt_lon FROM shapes where shape_id=' + request.query.shape_id, (e, rows) => {
if (e) {
// error reading a row
data.push(e);
} else {
// success reading a row
data.push({
x: rows['shape_pt_lat'],
y: rows['shape_pt_lon']
});
}
return data;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment