Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILIPP111007 committed Apr 10, 2024
1 parent e66c85b commit 2ac753f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
27 changes: 19 additions & 8 deletions frontend/src/API/Fetch.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
import { HttpMethod } from "@data/enums"


const headers = {
"Content-Type": "application/json; charset=utf-8",
"Access-Control-Allow-Origin": "*"
}



export default async function Fetch({ action, method, body }) {

var url = `${process.env.REACT_APP_SERVER_URL}${action}`
// var url = `${process.env.REACT_APP_SERVER_URL}${action}`

var url = `http://92.255.77.65:80/${action}`
// url = `http://92.255.77.65/${action}`

console.log(action, method)

if (method === HttpMethod.GET) {
var data = await fetch(url, {
method: "GET",
credentials: "same-origin",
headers: {
"Content-Type": "application/json; charset=utf-8",
}
headers: headers
})
.then((response) => response.json())
.then((data) => {
Expand All @@ -24,13 +35,13 @@ export default async function Fetch({ action, method, body }) {
return data

} else {

console.log(headers)
var data = await fetch(url, {
method: method,
credentials: "same-origin",
headers: {
"Content-Type": "application/json; charset=utf-8",
},
body: body ? JSON.stringify(body) : "",
headers: headers,
body: body ? JSON.stringify(body) : ""
})
.then((response) => response.json())
.then((data) => {
Expand Down
7 changes: 2 additions & 5 deletions frontend/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@ export default function App() {
var [predict, setPredict] = useState(0)

async function getPredict(date) {

console.log(date)

var data = await Fetch({ action: "api/v1/predict/", method: HttpMethod.GET })
var data = await Fetch({ action: "api/v1/predict/", method: HttpMethod.POST })

if (data && data.ok) {
// console.log(data)
setPredict(data.predict)
// setPredict(data.predict)
}
setPredict(Math.random())
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/PredictForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export default function PredictForm({ func }) {

return (
<>
<Form onSubmit={e => callFunc(e)}>
<Form.Group className="mb-3" controlId="formGroupEmail">
<Form formAction="POST" onSubmit={e => callFunc(e)}>
<Form.Group className="mb-3">
<InputGroup className="mb-3">
<Form.Control
type="date"
Expand Down

0 comments on commit 2ac753f

Please sign in to comment.