@@ -12,7 +12,7 @@ async function startServer()
|
|||||||
await createTables();
|
await createTables();
|
||||||
|
|
||||||
app.use('/api/auth', authRouter);
|
app.use('/api/auth', authRouter);
|
||||||
app.get('/api/', (req, res) => res.send('Backend running'));
|
app.get('/api', (req, res) => res.send('Backend running'));
|
||||||
|
|
||||||
app.listen(3001, () =>
|
app.listen(3001, () =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ router.post('/register', async(req, res) =>
|
|||||||
|
|
||||||
router.post('/login', async(req, res) =>
|
router.post('/login', async(req, res) =>
|
||||||
{
|
{
|
||||||
|
console.log("received login!");
|
||||||
const {username, password} = req.body;
|
const {username, password} = req.body;
|
||||||
const result = await authService.login(username, password);
|
const result = await authService.login(username, password);
|
||||||
res.status(result.status).json(result.data);
|
res.status(result.status).json(result.data);
|
||||||
|
|||||||
@@ -87,14 +87,14 @@ export class LoginWindow extends fenetre {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async connexion() {
|
async connexion() {
|
||||||
const response = await fetch("/api/login", {
|
const response = await fetch("/api/auth/login", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
username: "nom",
|
username: this.username.value,
|
||||||
password: "a"
|
password: this.password.value
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user