express 3

Section 27: An Introduction to Node.js - A Different JavaScript Environment

The goals 💪🏻What Exactly Is Node.js ✌🏻Writing Node.js Code 👍🏻Using Express.js 👊🏻Talking to a Database How to use File System const fs = require('fs'); fs.readFile('user-data.txt', (err, data) => { if (err) { console.log(err); return; } console.log(data.toString()); }); fs.writeFile('user-data.txt', 'username=Max', err => { if (err) { console.log(err); } else { console.log('Wrote to file!'); } })..

Section 19: NodeJS & HTML Files - Working with Templates : Working With Static & Dynamic Files

The goals 💪🏻Sending HTML Files as Responses ✌🏻Serving Static Files 👍🏻Working With Dynamic Templates A project we are gonna build through this section res.send vs res.sendFile You can't use both res.send() and res.sendFile() in the same route and method because every request has only one response and each one is called first, that's your response. You're trying to pass a filename to render, but i..

Section 18: Easier NodeJS Development with ExpressJS: Using a Third-Party NodeJS Library

The goals 💪🏻What & Why? ✌🏻Request & Response Handling With Express 👍🏻Parsing & Storing User Input Node Package Manager (NPM) Try Express const express = require('express'); const app = express(); app.get('/currenttime', function(req, res) { res.send('' + new Date().toISOString() + ''); }); // localhost:3000/currenttime app.get('/', function(req, res) { res.send('Hello World!'); }); // localhost:..