123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- export const fetchPathKeys = () => {
- return fetch("http://localhost:5000/get-path")
- .then(res => {
- if(res.status >= 400) {
- throw new Error("Server responds with error!");
- }
- return res.json();
- }).then(data => {
- return Object.keys(data)
- }, err => {
- console.log(err)
- });
- }
- export const fetchPaths = () => {
- return fetch("http://localhost:5000/get-path")
- .then(res => {
- if(res.status >= 400) {
- throw new Error("Server responds with error!");
- }
- return res.json();
- }).then(data => {
- return data
- }, err => {
- console.log(err)
- })
- }
- export function savePathToDb(){
- let json = JSON.stringify({
- "path": {
- "name": this.state.savePathKey,
- "coords": this.state.path
- }
- })
-
- let reqOptions = {
- method: 'POST',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json',
- },
- body: json
- }
-
- return fetch("http://localhost:5000/set-path", reqOptions)
- .then(res => {
- if(res.status >= 400) {
- throw new Error("Server responds with error!");
- }
- return res.json();
- })
- .then(data => {
- return data
- }, err => {
- console.log(err)
- })
- }
|