here is my file:
const express = require('express');
const path = require('path');
const app = express();
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'Basic-signupsignin-setup', '../pages', 'index.html'));
});
app.get('/database', (req, res) => {
res.sendFile(path.join(__dirname, 'Basic-signupsignin-setup', '../pages', 'db.js'));
});
app.listen(3000, () => {
console.log('server started');
});
inside of the directory is index.html that only links to '/database' which sends db.js
const users = new database();
function signUp(username, password, email, data) {
users.set(username, `${username},${password},${email},${data}`).then(() => {})
}
signUp("username", "password", "email", "data")
function signin(username, password) {
users.get(username).then(value => {
const data1 = value.split(",");
var username1 = data1[1];
var password1 = data1[2];
var email1 = data1[3]
var data2 = data1[4]
if (password1 == password) {
console.log(`JSON OG: ${data}`, `:JSON NOW: ${username1}, ${password1}, ${email1}, ${data2}`);
} else {
console.error("wrong password");
}
})
}
signin("username", "password");
it throws the errordatabase:1 Uncaught ReferenceError: database is not defined at database:1:15 (anonymous) @ database:1
how can i define database?
You need to install and import:
In yout terminal:
In the code: