From 9f14b74575ea680354ac664e327f7b813081ed2a Mon Sep 17 00:00:00 2001 From: Alfred Melch Date: Fri, 3 Jan 2020 02:06:32 +0100 Subject: [PATCH] add api with example usage --- src/api.js | 7 +++++++ src/index.js | 5 +++++ 2 files changed, 12 insertions(+) create mode 100644 src/api.js diff --git a/src/api.js b/src/api.js new file mode 100644 index 0000000..7dbf980 --- /dev/null +++ b/src/api.js @@ -0,0 +1,7 @@ +import Axios from 'axios' + +export function getMap(x, y) { + return Axios.get(`http://169.254.61.222:5000/generate/${x}/${y}`).then( + data => data.data + ) +} diff --git a/src/index.js b/src/index.js index a6fc942..446baf6 100644 --- a/src/index.js +++ b/src/index.js @@ -4,6 +4,7 @@ import React from 'react' import ReactDOM from 'react-dom' import { App } from './App' +import { getMap } from './api' function createRootElement() { const body = document.getElementsByTagName('body')[0] @@ -13,3 +14,7 @@ function createRootElement() { return root } ReactDOM.render(, createRootElement()) + +getMap(10, 20).then(map => { + console.log(map) +})