-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
37 lines (32 loc) · 872 Bytes
/
app.js
File metadata and controls
37 lines (32 loc) · 872 Bytes
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
29
30
31
32
33
34
35
36
37
const express = require("express");
const app = express();
const fetch = require("node-fetch");
const cors = require("cors");
const bodyParser = require("body-parser");
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.get("/", (req, res) => {
res.send("Works");
});
app.post("/map", (req, res) => {
const { start_lat, start_long, end_lat, end_long } = req.body;
let body = {
start_lat,
start_long,
end_lat,
end_long
};
console.log(body);
fetch(`https://stark-temple-37550.herokuapp.com/map`, {
method: "post",
body: JSON.stringify(body),
headers: { "Content-Type": "application/json" }
})
.then(res => res.json())
.then(data => res.send(data))
.catch(err => res.send(err));
});
app.listen(process.env.PORT || 8888, () => {
console.log("Server started");
});