31/1/22 11:48 NodeJS - REST API - Cliente: DESARROLLO DE APLICACIONES WEB Y MÓVILES
NodeJS - REST API - Cliente
Node.js permite levantar mecanismos (REST API) de comunicación con otras piezas de
código.
Cliente básico
Desde la línea de comandos:
Clona el proyecto, con: git clone
https://github.com/DAWFIEC/sitioRESTAPIClient.git
(https://github.com/DAWFIEC/sitioRESTAPIClient.git)
Accede a la carpeta del proyecto: cd sitioRESTAPIClient
Cámbiate a la rama: git checkout basic-client
Instala los módulos: npm install
Verifica que funcione correctamente al levantar los servicios: npm start
Abra en el navegador el URL http://localhost:4200/ (http://localhost:4200/)
Consumo de recursos
Modifique el componente src/app/app.component, en:
En el controlador src/app/app.component.ts:
Haga un requerimiento asincrónico con fetch, al URL
http://localhost:3001/clientes (http://localhost:3001/clientes)
Guarde el resultado del requerimiento en el atributo clientes.
En la vista src/app/app.component.html:
Agregue la directiva *ngFor para recorrer el atributo clientes.
https://aulavirtual.espol.edu.ec/courses/3423/pages/nodejs-rest-api-cliente?module_item_id=138839 1/2
31/1/22 11:48 NodeJS - REST API - Cliente: DESARROLLO DE APLICACIONES WEB Y MÓVILES
Tome como referencia el sitio Angular ngFor la directiva y sus opciones
(https://www.arquitecturajava.com/angular-ngfor-y-sus-opciones/) para utilizar la
directiva *ngFor.
Muestre los atributos id, nombre, apellido y fechaNacimiento en la tabla.
Fuentes
Angular 12 + Node.js Express + MySQL example: CRUD Application - BezKoder. (2021).
Retrieved 11 August 2021, from https://www.bezkoder.com/angular-12-node-js-
express-mysql/ (https://www.bezkoder.com/angular-12-node-js-express-mysql/)
Table V02. (2021). Retrieved 11 August 2021, from
https://colorlib.com/wp/template/table-02/ (https://colorlib.com/wp/template/table-02/)
Caules, C. (2018). Angular ngFor la directiva y sus opciones. Retrieved 15 December 2021,
from https://www.arquitecturajava.com/angular-ngfor-y-sus-opciones/
(https://www.arquitecturajava.com/angular-ngfor-y-sus-opciones/)
https://aulavirtual.espol.edu.ec/courses/3423/pages/nodejs-rest-api-cliente?module_item_id=138839 2/2