Nodeschool Passau
Learning Molecules
Once you got started by attending a Beginner's Track session, you may choose from any of the workshopper modules listed on the NodeSchool page.
In order to facilitate discussions with peers in a NodeSchool Passau workshop, we provide what we call "Learning Molecules" - ideas for tiny projects you may work on, instead of or in addition to the workshopper modules.
In all NodeSchool Passau workshops, a mentor will present one of these Learning Molecules to introduce you to the main topics of the molecule.
Learning Molecule: JSON Server
When you build a web app, you'll probably want to be able to demonstrate the app without writing a full-blown backend. JSON Server is an npm module which facilitates exactly this.
Steps:
- create a new folder for this project
- create a package.json file by running yarn init -y
- add JSON Server: yarn add json-server
- add a script entry to your package.json: "scripts": { "start": "json-server --watch db.json" }
- Follow the post Create a REST API With JSON Server
Learning Molecule: HTTP Server
When you start building HTTP-based applications in Node.js, the http/https modules are the ones you will interact with. Now, let's create your first Node.js HTTP server and learn more about the http/https and express module.
Steps:
- create a new folder for this project
- create a package.json file by running yarn init -y
- Follow the post Node Hero - Your First Node.js HTTP Server
- Use yarn instead of npm
Learning Molecule: HTTP Requests
External APIs can be important sources for your application. Send requests to get the relevant informations and show it on your website.
Steps:
- Create a new folder for this project
- Create a package.json file by running yarn init -y
- Follow the post Node Hero - Node.js Request Module Tutorial
- Use yarn instead of npm
- Because we don’t have an access key for accuweather, adjust the described solution to use weather api from yahoo. The relevant Endpoint is described here: Yahoo Weather API
The server should be reachable via http://localhost/passau and display e.g.
Hello, the weather for passau is Cloudy, with 65°F
- For alternate ways of implementing HTTP requests with Node.js, read the article 4 ways for making HTTP(S) requests with Node.js
- We recommend using the module
node-fetch
, because the fetch api is a modern api implemented in all browsers for making HTTP requests from JavaScript - Read about the browser Fetch API, create a small HTML page and make a request to the weather api (using a hard-coded path) from within the web page
Learning Molecule: Cheerio
With the Node.js module cheerio you can load the html part of a website into your Node.js function and work with it like an object. In this tutorial you scrap the news from a website and display it in the console.
Steps:
- create a new folder for this project
- create a package.json file by running yarn init -y
- add JSON Server: yarn add json-server
- Follow the post How To Use node.js, request and cheerio to Set Up Simple Web-Scraping
- Adjust your solution to use your favorite request module instead of the request module