Shiori Suzuki

Sign in

fs object

Photo by S Migaj on Unsplash

Require fs module

var fs = require(‘fs’);

Read files

fs.readFile( fileName, encoding, function() {} )
  • The name of the file you load
  • encoding
  • The function called after finishing readFile()

Create files

  • fs.appendFile():Add contents into the file. Create a null file if there is no such file.
var fs = require(‘fs’);
fs.appendFile(‘mynewfile1.txt’, ‘Hello content!’, function (err) {
if (err) throw err;
console.log(‘Saved!’);
});
  • fs.open():If arg2 is “w(writing)”, specified file will opened. Create a null file if there is no such file.
var fs = require(‘fs’);
fs.open(‘mynewfile2.txt’, ‘w’, function (err


Photo by Paul Esch-Laurent on Unsplash

Create a new module

  1. Creating a folder
mkdir folder-name
npm init
package name: (the name of your module)
version: (1.0.0) /** default **/
description: description of your module
entry point: (index.js)
test command:
git repository: your git repository URL
keywords: keyword people search for
author: name <email@gmail.com> (your website)
license: (ISC)
exports.functionName = function()…

Photo by Ashwini Chaudhary on Unsplash

In JS file

http

const http = require(‘http’);

createServer

const server = http.createServer((request, response) => {
Displayed screen
})


Photo by Food Photographer | Jennifer Pallian on Unsplash

What is a Cookie?


Photo by John McArthur on Unsplash

APIs

Performance

How to use Express


Photo by sydney Rae on Unsplash

Run the `npx` command in Terminal.

npx create-next-app next_app

Perform basic operations on the created project.

npm run devrun dev
npm run build
npm start

Project structure

.next

node_modules

pages


Photo by Olesya Grichina on Unsplash

When you want to create multiple pages.

When you want to get data from the server and use it as a state

When you want to get data from the server and use it as a state. A typical example is `Next.js`.

Next.js is a package that integrates various libraries into React.

Specific features of Next.js.

SSG and SSR support

SSG(Static Site Generator)


Photo by Nikola Johnny Mirkovic on Unsplash

Different usage of “State”.

Class Component

Function components

Function components are always reloaded.

Class components are kept in state.

Function components are not stored.


Photo by Kelly Sikkema on Unsplash

Components in a project

Files related to what is displayed on the screen

public folder

src folder

Shiori Suzuki

I’m a front-end web developer based in Vancouver, studying CICCC, an web and mobile app development course. https://shiory602.github.io/portfolio/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store