-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-api-working.html
More file actions
96 lines (85 loc) · 3.57 KB
/
test-api-working.html
File metadata and controls
96 lines (85 loc) · 3.57 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>API Test</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
.test-result { margin: 10px 0; padding: 10px; border-radius: 5px; }
.success { background-color: #d4edda; color: #155724; }
.error { background-color: #f8d7da; color: #721c24; }
input, button { padding: 10px; margin: 5px; }
</style>
</head>
<body>
<h1>🔍 API Test Page</h1>
<div>
<label for="phoneInput">Phone Number:</label>
<input type="text" id="phoneInput" placeholder="e.g., 1234567890" value="1234567890">
<button onclick="testPhoneLookup()">Test Phone Lookup</button>
</div>
<div id="results"></div>
<h3>📱 Available Test Numbers:</h3>
<ul>
<li><strong>Users:</strong> 9702226623, 1234567890, 1111111111, 0987654321</li>
<li><strong>Merchants:</strong> 9876543210, 9876543212, 9876543214, 9876543216</li>
</ul>
<script>
async function testPhoneLookup() {
const phone = document.getElementById('phoneInput').value;
const resultsDiv = document.getElementById('results');
resultsDiv.innerHTML = '<div class="test-result">🔄 Testing...</div>';
try {
const response = await fetch(`http://localhost:3000/api/users/find-by-phone/${phone}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
});
const data = await response.json();
if (response.ok && data.success) {
const user = data.data.user;
resultsDiv.innerHTML = `
<div class="test-result success">
✅ SUCCESS! Found user: ${user.firstName} ${user.lastName}<br>
📧 Email: ${user.email}<br>
📱 Phone: ${user.phone}<br>
👤 Type: ${user.userType || 'user'}<br>
✅ Verified: ${user.isVerified}
</div>
`;
} else {
resultsDiv.innerHTML = `
<div class="test-result error">
❌ FAILED: ${data.message || 'Unknown error'}<br>
📡 Status: ${response.status}
</div>
`;
}
} catch (error) {
resultsDiv.innerHTML = `
<div class="test-result error">
❌ NETWORK ERROR: ${error.message}<br>
🔗 Make sure the server is running at http://localhost:3000
</div>
`;
}
}
// Test all numbers on page load
window.onload = function() {
const testNumbers = ['1234567890', '9876543210', '9702226623'];
let index = 0;
function testNext() {
if (index < testNumbers.length) {
document.getElementById('phoneInput').value = testNumbers[index];
testPhoneLookup();
index++;
setTimeout(testNext, 2000);
}
}
setTimeout(testNext, 1000);
};
</script>
</body>
</html>