-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
131 lines (116 loc) · 2.89 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// app.js
import axios from 'axios';
// Configure base API settings
const apiClient = axios.create({
baseURL: 'YOUR_API_BASE_URL', // Replace with your actual API base URL
headers: {
'Content-Type': 'application/json',
'Platform': 'android',
},
});
// Import your API functions
import {
getWeatherData,
getRoutes,
getEvents,
getTodoItems,
processTodoItems,
getCourses,
processCourses,
getCourseInfo
} from './src/api/index.js';
apiClient.interceptors.request.use(
(config) => {
return config;
},
(error) => {
return Promise.reject(error);
}
);
// Test functions
const testWeather = async () => {
try {
const data = await getWeatherData();
console.log('Weather test:', data);
return data;
} catch (error) {
console.error('Weather test failed:', error);
throw error;
}
};
const testRoutes = async () => {
try {
const data = await getRoutes();
console.log('Routes test:', data);
return data;
} catch (error) {
console.error('Routes test failed:', error);
throw error;
}
};
const testEvents = async () => {
try {
const data = await getEvents();
console.log('Events test:', data);
return data;
} catch (error) {
console.error('Events test failed:', error);
throw error;
}
};
const testTodos = async () => {
try {
const items = await getTodoItems();
const processed = await processTodoItems(items);
console.log('Todos test:', processed);
return processed;
} catch (error) {
console.error('Todos test failed:', error);
throw error;
}
};
const testCourses = async () => {
try {
const courses = await getCourses();
const processed = await processCourses(courses);
console.log('Courses test:', processed);
return processed;
} catch (error) {
console.error('Courses test failed:', error);
throw error;
}
};
const testCourseInfo = async () => {
try {
const info = await getCourseInfo('COMP SCI 544');
console.log('Course info test:', info);
return info;
} catch (error) {
console.error('Course info test failed:', error);
throw error;
}
};
const testAllCourses = async () => {
try {
// First get and process courses from Canvas
const courses = await getCourses();
// Step 2: Process Courses
const processedCourses = await processCourses(courses);
const courseInfos = [];
for (const course of processedCourses) {
try {
const info = await getCourseInfo(course);
courseInfos.push(info);
} catch (infoError) {
console.error(`Error fetching info for ${course}:`, infoError);
}
}
console.log('Course Latitude:', courseInfos[0].weeklyMeetings[0].latitude);
console.log('Course Longitude:', courseInfos[0].weeklyMeetings[0].longitude);
return courseInfos;
} catch (error) {
console.error('Courses test failed:', error);
throw error;
}
};
testAllCourses();