Test
This commit is contained in:
30
scripts/testLogin.js
Normal file
30
scripts/testLogin.js
Normal file
@@ -0,0 +1,30 @@
|
||||
const fetch = require('node-fetch');
|
||||
const bcrypt = require('bcryptjs');
|
||||
|
||||
async function testLogin() {
|
||||
try {
|
||||
console.log('Testing admin login...');
|
||||
const loginRes = await fetch('http://localhost:4000/api/admin/login', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
username: 'admin',
|
||||
password: 'admin123'
|
||||
})
|
||||
});
|
||||
|
||||
console.log('Response status:', loginRes.status);
|
||||
const data = await loginRes.json();
|
||||
console.log('Response data:', data);
|
||||
|
||||
if (loginRes.ok) {
|
||||
console.log('Login successful! Token:', data.token);
|
||||
} else {
|
||||
console.log('Login failed:', data.error);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error:', err.message);
|
||||
}
|
||||
}
|
||||
|
||||
testLogin();
|
||||
Reference in New Issue
Block a user