This commit is contained in:
@@ -6,7 +6,7 @@ module.exports = (fastify, opts, done) => {
|
||||
url.searchParams.append('query', req.params.id)
|
||||
url.searchParams.append('limit', 16)
|
||||
url.searchParams.append('type', 'schedule')
|
||||
fetch(url).then((res) => reply.send(res.data));
|
||||
fetch(url).then((res) => reply.send(res.json()));
|
||||
} else {
|
||||
return reply.send([]);
|
||||
}
|
||||
@@ -14,10 +14,20 @@ module.exports = (fastify, opts, done) => {
|
||||
});
|
||||
fastify.get("/place/:id", async (req, reply) => {
|
||||
if (req.params.id) {
|
||||
const url = new URL("https://nominatim.openstreetmap.org/");
|
||||
const url = new URL("https://nominatim.openstreetmap.org/search");
|
||||
url.searchParams.append('format', 'jsonv2')
|
||||
url.searchParams.append('q', req.params.id)
|
||||
fetch(url).then((res) => reply.send(res.data));
|
||||
|
||||
let bb = JSON.parse(req.query.bb)
|
||||
if(bb){
|
||||
url.searchParams.append('viewbox', `${bb[0][0]},${bb[0][1]},${bb[1][0]},${bb[1][1]}`)
|
||||
url.searchParams.append('bounded', 1)
|
||||
}
|
||||
fetch(url).then((res) => {
|
||||
if( !res.ok) throw new Error("Nominatim Error")
|
||||
return res.json()
|
||||
}).then(res=>{
|
||||
reply.send(res)});
|
||||
} else {
|
||||
return reply.send([]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user