add api with example usage

This commit is contained in:
Alfred Melch 2020-01-03 02:06:32 +01:00
parent 3c0d84c628
commit 9f14b74575
2 changed files with 12 additions and 0 deletions

7
src/api.js Normal file
View File

@ -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
)
}

View File

@ -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(<App />, createRootElement())
getMap(10, 20).then(map => {
console.log(map)
})