23 lines
757 B
JavaScript
23 lines
757 B
JavaScript
async function test() {
|
|
const loginRes = await fetch('http://localhost:3001/api/v1/auth/login', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ email: 'photomember@travel.com', password: '123456' })
|
|
});
|
|
const loginData = await loginRes.json();
|
|
|
|
if (loginRes.ok) {
|
|
const token = loginData.access_token;
|
|
const usersRes = await fetch('http://localhost:3001/api/v1/users?q=owner@travel.com', {
|
|
headers: { 'Authorization': `Bearer ${token}` }
|
|
});
|
|
console.log('Users status:', usersRes.status);
|
|
const usersData = await usersRes.json();
|
|
console.log('Users data:', usersData);
|
|
} else {
|
|
console.error('Login failed:', loginData);
|
|
}
|
|
}
|
|
|
|
test().catch(console.error);
|