Spaces:
Sleeping
Sleeping
Download frontend/src/services/api.js from notha99y/timetablev2: direct link, hf CLI and curl.
- Browser
- Download file 1.43 kB
-
https://huggingface.co/spaces/notha99y/timetablev2/resolve/main/frontend/src/services/api.js
- Command line
-
hf download hf://spaces/notha99y/timetablev2/frontend/src/services/api.js
-
curl -L -o api.js https://huggingface.co/spaces/notha99y/timetablev2/resolve/main/frontend/src/services/api.js
1.43 kB
| import axios from 'axios'; | |
| const API_BASE_URL = process.env.REACT_APP_API_URL || (process.env.NODE_ENV === 'production' ? '' : 'http://localhost:8000'); | |
| const api = axios.create({ | |
| baseURL: API_BASE_URL, | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| }, | |
| }); | |
| export const searchTimetable = async (searchRequest) => { | |
| try { | |
| console.log('Sending request to backend:', JSON.stringify(searchRequest, null, 2)); | |
| const response = await api.post('/api/search', searchRequest); | |
| return response.data; | |
| } catch (error) { | |
| console.error('Error searching timetable:', error); | |
| if (error.response) { | |
| console.error('Response status:', error.response.status); | |
| console.error('Response data:', error.response.data); | |
| } | |
| throw error; | |
| } | |
| }; | |
| export const uploadCSV = async (file) => { | |
| try { | |
| const formData = new FormData(); | |
| formData.append('file', file); | |
| const response = await api.post('/api/upload-csv', formData, { | |
| headers: { | |
| 'Content-Type': 'multipart/form-data', | |
| }, | |
| }); | |
| return response.data; | |
| } catch (error) { | |
| console.error('Error uploading CSV:', error); | |
| throw error; | |
| } | |
| }; | |
| export const validateModule = async (module) => { | |
| try { | |
| const response = await api.post('/api/validate-module', module); | |
| return response.data; | |
| } catch (error) { | |
| console.error('Error validating module:', error); | |
| throw error; | |
| } | |
| }; |