Skip to content

Latest commit

 

History

History
73 lines (47 loc) · 3.36 KB

Readme 09.05.md

File metadata and controls

73 lines (47 loc) · 3.36 KB

Today 09.05

Node JS

node.js

Mejoramos la app [operations](Calculator Node) y la modificamos para recoger directamente argumentos desde Node

If we want ignored any file for Git, must be create a file whit the name .gitignore and into put the name of the folders and files for ignore the Git

Si introducimos en consola el comando env, obtenemos todas las variables de entorno de nuestro sistema operativo y podemos leerla mediante Node.

Por ejemplo con el set MY_name=Toni&&node app.js podremos modificar alguna variable de entorno que hemos visto anteriormente.

Lo podremos ver si en nuestra app escribimos un console.log, como el siguiente. console.log(process.env) y veremos como la variable de entorno a cambiado al lanzar el comando // set MY_NAME=Toni&&node app.js

Now checked the next exercise [Node Exercises](Node Exercises). In this exercises up the litle server listening on port that in the moment of launch the app is specificy in the moment you call the node app. On windows with the next command set PORT=3000&&node app.js

Modulo request

  1. Generate the file package.json with this command in console npm ini
  2. Install dependencies, npm install request if add the command --save automaticaly update the package.json with the new package.
  3. Create the file for request HTML webpages:
var request = require('request')
request('http://www.google.com', function (error, response, body) {
  console.log('error:', error) // Print the error if one occurred
  console.log('statusCode:', response && response.statusCode) // Print the response status code if a response was received
  console.log('body:', body) // Print the HTML for the Google homepage.
})

Exercices:

Exercises: Demo Get Url Request

Practice with node https://nodeschool.io/

npm install learyounode

Learn You Node

Asynchronous programming in Node