Created
September 21, 2016 15:33
-
-
Save anonymous/868447ebece55338b5cd3c3f68ee26d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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