-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi-mock.js
More file actions
36 lines (32 loc) · 1.03 KB
/
api-mock.js
File metadata and controls
36 lines (32 loc) · 1.03 KB
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
export const authAPI = {
// Mock login endpoint
async login(email, password) {
// Simulate API delay
await new Promise(resolve => setTimeout(resolve, 1000));
// Mock validation (replace with real backend logic)
if (email === 'user@example.com' && password === 'password123') {
return {
token: 'mock-jwt-token-123',
user: { id: 1, name: 'John Doe', email }
};
} else {
throw new Error('Invalid email or password');
}
}
};
export const dataAPI = {
// Mock homepage data endpoint
async getHomepageData(token) {
await new Promise(resolve => setTimeout(resolve, 1000));
// Mock token validation
if (token !== 'mock-jwt-token-123') {
throw new Error('Invalid authentication token');
}
// Mock user activity data
return [
'Logged in at 9:00 AM',
'Updated profile at 10:30 AM',
'Received message from Jane'
];
}
};