Skip to content

Commit

Permalink
adding support for azure static web app env vars
Browse files Browse the repository at this point in the history
Signed-off-by: Tiago Barbosa <tbarbos@hotmail.com>
  • Loading branch information
t1agob committed May 15, 2024
1 parent 7652a15 commit c1972ae
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions frontend/src/components/OrderCommand.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Button } from '@headlessui/react'
import { useEffect, useState } from 'react';

type Props = {
food: string;
Expand All @@ -7,14 +8,28 @@ type Props = {
};


export async function fetchSettings() {

const response = await fetch('/api/settings');
return await response.json();
}


function OrderCommand({food, drink}: Props) {

const apiUrl = process.env.API_URL;
console.log("API URL: " + apiUrl);
const [settings, setSettings] = useState({});
useEffect(() => {

fetchSettings().then((settings) => {
setSettings(settings);
console.log(settings);
});
}, []);

console.log("API URL: " + JSON.stringify(settings));

function submitOrder() {
fetch(`${apiUrl}/order`, {
fetch(`https://cors-anywhere.herokuapp.com/http://51.8.246.178/order`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand Down

0 comments on commit c1972ae

Please sign in to comment.