-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
28 lines (28 loc) · 879 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const express = require("express");
const queryString = require("querystring");
const node_fetch_1 = require("node-fetch");
const app = express();
const apiKey = '';
app.get('/', (req, res) => {
const queryObj = {
origin: req.query.origin,
destination: req.query.destination,
key: apiKey,
mode: req.query.mode,
language: req.query.language,
region: req.query.region,
};
const stringQuery = queryString.stringify(queryObj);
node_fetch_1.default(`https://maps.googleapis.com/maps/api/directions/json?${stringQuery}`)
.then(mapRes => {
return mapRes.json();
})
.then((json) => {
return res.send(json);
})
.catch((err) => console.log(err));
});
app.listen(5000);
//# sourceMappingURL=app.js.map