Algorithm for finding app.post to sqlite database bug required

I remixed dreams-boilerplate by danielp73 and I can’t get the server.js app.post code to work to insert my form selection data into a specific table of the sqlite database.

Using the sqlite3 CLI on .data/sqlite.db works fine and I can open the database and use .tables to see the tables and use SELECT * FROM tablename; to see the records of a specific table. INSERT INTO also works and the inserted data appears on my Glitch preview ejs web pages.

app.get(‘/ideasList’, (req, res) => {
const sql = “SELECT * FROM ideasList”
db.all(sql, , (err, rows) =>{
if (err) {
return console.error(err.message);
}
res.render(‘pages/ideasList’, { model: rows });
});
});

This code works fine to show my ideasList table records on a separate web page.

I had the remixed application code working fine with two menu selection forms and an html file but in changing to using ejs files, I changed something in the code or the DISALLOW_WRITE setting such that my form data is no longer being posted to my sqlite database. Something similar is also happening with a remixed version of the dreams-boilerplate code where my submitted data is appearing on the html web page but is not being INSERTED INTO sqlite.db nor persisted between sessions. When I start the app again, I get null values in a bulleted list for the data I added in a previous session.

When I click on my first of the two form selection submit buttons I get nothing. When I click on the second form selection submit button I get a “Cannot POST /getAuthors” message.

Where should I start my search for the bug?

  1. DISALLOW_WRITE in .env?
    I tried setting a value for DISALLOW_WRITE in .env but I’m not sure I used the proper syntax with “=FALSE” on the right. Did I need to monkey with it in the first place? How can I reset it properly if I changed it?
  2. Should I check my route names such as /addGreatIdea or /addAuthor?
  3. Could it be an incorrect variable name? I have a lot of similar variable names with camelcase so maybe I put ideaslist rather than ideasList etc.
  4. Why doesn’t console.log(add to authorsList ${request.body}); run?
    should it be request.body.author? Changing just that didn’t work.
  5. Should the value for urlencoded be true or false?
    app.use(bodyParser.urlencoded({ extended: true }));
  6. why does the client-side fetch() api work in the dreams-boilerplate when I’m using Node.js 16 and fetch became experimental in Node.js 15 and stable in Node.js 21?
    I’m trying out use of fetch() code from basic tutorials but there are some tutorials that add await and async for some reason. People using server-side fetch are adding axios and node-fetch.
  7. why doesn’t a console.log message at the top of my client.js code run but the rest of the client.js code seems to run?
  8. There is another concern about express 4.16.3 and body parser and express.json that I’m not going to address unless it’s necessary.

check the route methods. or more likely, check how a POST request ends up going to something called getAuthors

can you look up the code that uses this environment variable, you might be able to see from that what values it accepts

probably not, it would give you a different ‘page not found’ kind of error if something like that were misspelled

‘not running’ is distinct from ‘request.body is wrong.’ not running results in no message, request.body being wrong results in something like add to authorsList undefined or add to authorsList [object Object] being logged. you can determine which it is

take a look at the documentation for extended, it lists some specific features it enables. I have a few apps that don’t enable it. haven’t seen how you are using it though, so I’m not particularly answering true or false

weird, node.js shouldn’t affect the availability of fetch on the client. what’s saying that it’s related at all?

there could theoretically be a console.clear() call, but I’d recommend you write up a minimal reproducible example of this

:person_in_lotus_position: