-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Objective:
Set up placeholders for API calls within the useTopics function to prepare for future backend integration. For now, use mock data for trending topics and query filtering while keeping the structure ready for actual API requests.
Tasks
-
Set Up Axios
- Install
axiosto standardize API call structure for future integration. - Command:
npm install axiosoryarn add axios
- Install
-
Configure Mock Data & API Call Structure
- Create a structure for the
submitQueryfunction to handle API calls. - Wrap the API call in a conditional check to return mock data if the backend isn’t available.
- Create a structure for the
-
Replace Dummy Trending Topics with Mock Data in
submitQuery- Replace the existing trending topics filter logic with a simulated API call.
- Use the following mock data response to mimic trending topics:
const mockTrendingResponse = { data: { topics: ['data science', 'biology', 'ai', 'longevity', 'trading'] } };
- Update
searchOptionswith the filtered results based onquery.
-
Implement Error and Loading States
- Keep existing error and loading states to maintain a responsive UI.
- Ensure the error state displays if no topics match the query.
-
Example of
submitQueryFunction with Mock Dataimport axios from 'axios'; const submitQuery = async () => { loading.value = true; try { // Use mock data for now, but structure this for future API integration const response = mockTrendingResponse; searchOptions.value = response.data.topics.filter((topic) => topic.toLowerCase().includes(query.value?.toLowerCase()?.trim() || "") ); error.value = searchOptions.value.length ? '' : 'No relevant topics are discussed on this server'; } catch (e) { error.value = 'Failed to fetch topics from the server.'; } finally { loading.value = false; } };
Acceptance Criteria
-
submitQueryis structured to handle an API call with mock data in place. - Trending topics are updated based on
query, and error/loading states are displayed correctly. - Easy-to-swap logic for replacing mock data with actual API response when backend is ready.
This will allow the frontend to function with mock data, while the structure is ready for actual API requests once the backend is live.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request