feat(frontend): setup

This commit is contained in:
Julian Tölle 2020-01-26 19:07:15 +01:00
parent db62d5d908
commit f14eda16ac
33 changed files with 15076 additions and 22 deletions

View file

@ -0,0 +1,37 @@
import React, { useState } from "react";
import { useAuth0 } from "../react-auth0-spa";
const ExternalApi = () => {
const [showResult, setShowResult] = useState(false);
const [apiMessage, setApiMessage] = useState("");
const { getTokenSilently } = useAuth0();
const callApi = async () => {
try {
const token = await getTokenSilently();
const response = await fetch("/api/v1/connections", {
headers: {
Authorization: `Bearer ${token}`
}
});
const responseData = await response.json();
setShowResult(true);
setApiMessage(responseData);
} catch (error) {
console.error(error);
}
};
return (
<>
<h1>External API</h1>
<button onClick={callApi}>Ping API</button>
{showResult && <code>{JSON.stringify(apiMessage, null, 2)}</code>}
</>
);
};
export default ExternalApi;