0% encontró este documento útil (0 votos)
67 vistas2 páginas

Guía Básica: NodeJS y REST API Cliente

Este documento explica cómo desarrollar un cliente básico para consumir una API REST creada con Node.js. Indica que se debe clonar un proyecto de ejemplo de GitHub, instalar los módulos necesarios y ejecutar los servicios. Luego, se debe hacer una petición asíncrona a la API para obtener los recursos, guardarlos y mostrarlos en la vista usando la directiva *ngFor de Angular.

Cargado por

otakun
Derechos de autor
© © All Rights Reserved
Nos tomamos en serio los derechos de los contenidos. Si sospechas que se trata de tu contenido, reclámalo aquí.
Formatos disponibles
Descarga como PDF, TXT o lee en línea desde Scribd
0% encontró este documento útil (0 votos)
67 vistas2 páginas

Guía Básica: NodeJS y REST API Cliente

Este documento explica cómo desarrollar un cliente básico para consumir una API REST creada con Node.js. Indica que se debe clonar un proyecto de ejemplo de GitHub, instalar los módulos necesarios y ejecutar los servicios. Luego, se debe hacer una petición asíncrona a la API para obtener los recursos, guardarlos y mostrarlos en la vista usando la directiva *ngFor de Angular.

Cargado por

otakun
Derechos de autor
© © All Rights Reserved
Nos tomamos en serio los derechos de los contenidos. Si sospechas que se trata de tu contenido, reclámalo aquí.
Formatos disponibles
Descarga como PDF, TXT o lee en línea desde Scribd

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

También podría gustarte