Import of glitchdotcom/glitch-hello-node

This commit is contained in:
Glitch (glitch-hello-node) committed 2021-06-28 13:40:23 +00:00
1 parent 5caccbf885
commit 4e508b417c
6 files changed
+768 -81

No files matched your search

+7 -16
View File
@@ -4,6 +4,10 @@ This project includes a Node.js server script and a web page that connects to it
[Node.js](https://nodejs.org/en/about/) is a popular runtime that lets you run server-side JavaScript. This project uses the [Fastify](https://www.fastify.io/) framework and explores basic templating with [Handlebars](https://handlebarsjs.com/).
## Prerequisites
You'll get best use out of this project if you're familiar with basic JavaScript. If you've written JavaScript for client-side web pages this is a little different because it uses server-side JS, but the syntax is the same!
## What's in this project?
← `README.md`: That’s this file, where you can tell people what your cool website does and how you built it.
@@ -22,24 +26,11 @@ This project includes a Node.js server script and a web page that connects to it
← `src/seo.json`: When you're ready to share your new site or add a custom domain, change SEO/meta settings in here.
## Next steps 🚀
## Try this next 🏗️
Let's keep track of the submitted favorites using an array. First add this code near the top of `server.js`:
Take a look in `TODO.md` for next steps you can try out in your new site!
```js
const favorites = [];
```
In the `POST` route, inside the `if(color)` block, add this code to save the submitted value to the array, and write it to the console:
```js
favorites.push(color);
console.log(favorites);
```
Click __Tools__ > __Logs__ at the bottom of Glitch to see the log statement in action when you submit new colors through the form.
Clearly this is not a robust data storage approach and won't persist for long! Your Node apps can use a variety of databases, like [SQLite](https://glitch.com/~hello-sqlite) and [Airtable](https://glitch.com/~airtable-guestbook-starter).
___Want a basic template version of this project to build your own Node.js app? Check out [Minimal Node](https://glitch.com/edit/#!/remix/glitch-mvp-node)!___
![Glitch](https://cdn.glitch.com/a9975ea6-8949-4bab-addb-8a95021dc2da%2FLogo_Color.svg?v=1602781328576)