ChandimaPrabath commited on
Commit
efe4d60
·
1 Parent(s): 4722f01
frontend/public/config.json DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "apiUrl": "https://unicone-studio-hanskingdom.hf.space"
3
- }
4
-
 
 
 
 
 
frontend/src/App.js CHANGED
@@ -1,33 +1,25 @@
 
1
  import React, { useState, useEffect } from 'react';
2
  import axios from 'axios';
 
3
  import logo from './logo.svg';
4
  import './App.css';
5
 
6
  function App() {
7
  const [data, setData] = useState(null);
8
  const [error, setError] = useState(null);
9
- const [apiUrl, setApiUrl] = useState('');
10
 
11
  useEffect(() => {
12
- // Fetch configuration file
13
- fetch('/config.json')
14
- .then(response => response.json())
15
- .then(config => {
16
- setApiUrl(config.apiUrl);
17
-
18
- // Fetch data from the backend
19
- axios.get(`${config.apiUrl}/api/film/all`)
20
- .then(response => {
21
- setData(response.data);
22
- })
23
- .catch(err => {
24
- setError(err);
25
- });
26
  })
27
  .catch(err => {
28
  setError(err);
29
  });
30
- }, []);
31
 
32
  return (
33
  <div className="App">
 
1
+ // src/App.js
2
  import React, { useState, useEffect } from 'react';
3
  import axios from 'axios';
4
+ import config from './config'; // Import the config
5
  import logo from './logo.svg';
6
  import './App.css';
7
 
8
  function App() {
9
  const [data, setData] = useState(null);
10
  const [error, setError] = useState(null);
11
+ const apiUrl = config.apiUrl;
12
 
13
  useEffect(() => {
14
+ // Use the API URL from the config
15
+ axios.get(`${apiUrl}/api/film/all`)
16
+ .then(response => {
17
+ setData(response.data);
 
 
 
 
 
 
 
 
 
 
18
  })
19
  .catch(err => {
20
  setError(err);
21
  });
22
+ }, [apiUrl]);
23
 
24
  return (
25
  <div className="App">
frontend/src/config.js ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ // src/config.js
2
+ const config = {
3
+ apiUrl: 'https://unicone-studio-hanskingdom.hf.space', // Update this URL as needed
4
+ };
5
+
6
+ export default config;
7
+
frontend/src/setupTests.js DELETED
@@ -1,5 +0,0 @@
1
- // jest-dom adds custom jest matchers for asserting on DOM nodes.
2
- // allows you to do things like:
3
- // expect(element).toHaveTextContent(/react/i)
4
- // learn more: https://github.com/testing-library/jest-dom
5
- import '@testing-library/jest-dom';