Can I send data to a Node+Express backend without a true Database?

Hello,

I am building a small bedtime checklist app (to encourage my kids to just please, get ready for bed :smile: ) and I’ve reached a point that I need to send data to the backend so my Express script can determine where to send the user next

Is this possible without implementing a true database? Currently I’m using IndexedDB on the browser to save the state of some checklist items. However, I’m wondering if I can take that data, post it via an express route, act on it on the server side, and based on the data, serve up the appropriate view.

I see in the docs there is a req.body object, but so far I have been unable to assign additional data to is. Is that possible? If not, is there another way I can send data with the post?

router.post("/bedtime-checklist", function (req, res, next) => {
  // can I access a variable from a frontend script here?

  //based on the above variable, add conditional here to send 
 // to complete page or incomplete page
  res.redirect("/bedtime-checklist-complete");
});

Unfortunately, this goes a bit beyond my familiarity with backend databases. One thing you could do is store the data in a cloud/serverless database like Firestore or AWS Lambda. Those may be extremely easy ways to get a checklist up and running with minimal effort.

1 Like

As always, I dont do react or server stuff, but…

I think you want to be looking at routing with parameters and handling post data in express.
Routing with parameters.
Route Parameters in Express - Mastering JS
Send the bit of data that the server needs to react to with this. Good for small amounts of data.
Handling POST data…
Handling any POST data in Express
Great for sending over larger amounts of data, anything jsonable.

But really if your not storing the checklist on the server then this could prolly just be a single page app. Once loaded from the server it shouldnt need it again and in the very least all decisions could be made on the client.

1 Like

Hey Kevin,

If you are using IndexedDB and you have a web app you are probably using a Service Worker?..

You could always route a response (view) through a Service Worker based off the headers or route in your fetch/ post request without using Node/ Express at all…

1 Like

@steve.mills I am using IndexedDB but not a service worker…yet. I don’t have any experience with service workers put perhaps this is my chance to try that out- thanks for the recommendation!

I had not thought of using parameters, I’m going to look into that. ‘Good for small amounts of data’- this describes my app, so it could turn out to be a good fit. Thanks!