Add complete React frontend with modern design and navigation
This commit is contained in:
34
frontend/src/services/api.ts
Normal file
34
frontend/src/services/api.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import axios from 'axios';
|
||||
|
||||
const API_BASE_URL = process.env.REACT_APP_API_URL || 'http://localhost:3000';
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: API_BASE_URL,
|
||||
headers: {
|
||||
'Content-Type': 'text/plain',
|
||||
},
|
||||
});
|
||||
|
||||
export interface BookData {
|
||||
books: string[];
|
||||
}
|
||||
|
||||
export const getBooks = async (): Promise<BookData> => {
|
||||
const response = await api.get('/books');
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const getBook = async (book: string): Promise<string> => {
|
||||
const response = await api.get(`/books/${book}`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const getChapter = async (book: string, chapter: string): Promise<string> => {
|
||||
const response = await api.get(`/books/${book}/${chapter}`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const checkHealth = async (): Promise<{ status: string; message: string }> => {
|
||||
const response = await api.get('/health');
|
||||
return response.data;
|
||||
};
|
||||
Reference in New Issue
Block a user