This commit is contained in:
parent
8a46f473eb
commit
1e10109bbe
@ -1,37 +1,23 @@
|
||||
const axios = require("axios");
|
||||
|
||||
module.exports = (fastify, opts, done) => {
|
||||
fastify.get("/flight/:id", async (req, reply) => {
|
||||
const ENDPOINT = "https://www.flightradar24.com/v1/search/web/find";
|
||||
const FORMAT = "-";
|
||||
if (req.params.id) {
|
||||
axios
|
||||
.get(ENDPOINT, {
|
||||
params: {
|
||||
format: FORMAT,
|
||||
query: req.params.id,
|
||||
limit: 16,
|
||||
type: "schedule",
|
||||
},
|
||||
})
|
||||
.then((res) => reply.send(res.data));
|
||||
const url = new URL("https://www.flightradar24.com/v1/search/web/find");
|
||||
url.searchParams.append('format', '-')
|
||||
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));
|
||||
} else {
|
||||
return reply.send([]);
|
||||
}
|
||||
return reply;
|
||||
});
|
||||
fastify.get("/place/:id", async (req, reply) => {
|
||||
const ENDPOINT = "https://nominatim.openstreetmap.org/";
|
||||
const FORMAT = "jsonv2";
|
||||
if (req.params.id) {
|
||||
axios
|
||||
.get(ENDPOINT, {
|
||||
params: {
|
||||
format: FORMAT,
|
||||
q: req.params.id,
|
||||
},
|
||||
})
|
||||
.then((res) => reply.send(res.data));
|
||||
const url = new URL("https://nominatim.openstreetmap.org/");
|
||||
url.searchParams.append('format', 'jsonv2')
|
||||
url.searchParams.append('q', req.params.id)
|
||||
fetch(url).then((res) => reply.send(res.data));
|
||||
} else {
|
||||
return reply.send([]);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user