|
|
|
@ -2,14 +2,34 @@ import React, { useState, useEffect } from "react";
|
|
|
|
|
import axios from "axios"; |
|
|
|
|
|
|
|
|
|
export default function App() { |
|
|
|
|
let [blocks, setBlocks] = useState([]); |
|
|
|
|
|
|
|
|
|
let backendUrl: string = process.env.BACKEND_ADDRESS!; |
|
|
|
|
|
|
|
|
|
if (backendUrl === undefined) { |
|
|
|
|
throw Error("backend address not specified in ENV variable"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
console.log(backendUrl); |
|
|
|
|
|
|
|
|
|
async function fetchBlocks() { |
|
|
|
|
let result = await axios(backendUrl); |
|
|
|
|
return result.data.Blocks; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
axios.get("https://baconipsum.com/api/?type=meat-and-filler").then(res => { |
|
|
|
|
console.log(res.data); |
|
|
|
|
fetchBlocks().then(blocks => { |
|
|
|
|
setBlocks(blocks); |
|
|
|
|
}); |
|
|
|
|
}, []); |
|
|
|
|
|
|
|
|
|
let blocksComponent = blocks.map(block => { |
|
|
|
|
return <li key={block.hash}>{block.hash}</li>; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<div> |
|
|
|
|
<h1>Hello from App!</h1> |
|
|
|
|
<h1>{blocksComponent}</h1> |
|
|
|
|
</div> |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|