/usr/akts
F12
and stare at that beautiful prompt
>
>>>
and
[email protected]~$
?
btn.addEventListener("click", function() { ... };)
console.log('I ran immediately');
setTimeout(() => {
console.log('I ran after 3sec')
}, 3000);
setTimeout(() => {
console.log('I ran after 2sec')
}, 2000);
node
at your terminal.>
>>>
and [email protected]~$
?var, let, const
- ECMAScript${string} templates
JSON
- Arrays and Objects
- .map
and .filter
functions
and callbacks
Object
.method
and a function
.http://192.168.1.30:3000
http://localhost:3000
proto://host:port
httpd
aka apache
is a program (server), that typically runs on port 80
$ firefox http://localhost:80
mysqld
is a program (service) that runs on port 3306
mysql
the cli client connects to it like
$ mysql -u akts -h 10.10.20.30 -p
global
and process
objects.require()
and module.exports
npm
node
.$ mkdir our-proj
$ cd our-proj
$ npm init
$ ls # see the package.json file
npm
scripts?$ npm i --save decamelize
package.json
and our folder$ ls # see the node_modules folder
const http = require('http');
const port = 3000;
const server = http.createServer((request, response) => {
console.log(request.url);
response.end('Hello World!');
});
server.listen(port, (err) => {
if (err) {
return console.log('something bad happened', err)
}
console.log(`server is listening on ${port}`)
});
dev-tools
C - POST
R - GET
U - PUT
D - DELETE
2xx Success
4xx Client Error
5xx Server Error
/recipes
/recipes/1
GET /recipes # gets all recipes
GET /recipes/1 # gets detail about recipe with id 1
PUT /recipes/1 # update a data about recipe with id 1
POST /recipes # add a new recipe
DELETE /recipes/1 # remove a recipe entry with id 1