From 9683bd4883148850c7c771752c7404c6c03f0cde Mon Sep 17 00:00:00 2001 From: Traym17 <51390112+Traym17@users.noreply.github.com> Date: Mon, 18 Jul 2022 20:55:01 -0600 Subject: [PATCH 1/3] =?UTF-8?q?Creaci=C3=B3n=20servicio=20de=20registrar?= =?UTF-8?q?=20guardas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api-gateway/src/app.controller.ts | 17 +++ api-gateway/src/app.service.ts | 14 +++ .../src/users/users.controller.ts | 5 + web-ui/web-react/src/App.js | 3 + .../src/components/GuardasSeguridad.js | 108 ++++++++++++++++++ 5 files changed, 147 insertions(+) create mode 100644 web-ui/web-react/src/components/GuardasSeguridad.js diff --git a/api-gateway/src/app.controller.ts b/api-gateway/src/app.controller.ts index f3b09baf..ff3bfa32 100644 --- a/api-gateway/src/app.controller.ts +++ b/api-gateway/src/app.controller.ts @@ -22,6 +22,23 @@ export class AppController { user_type, status, date_entry); } + @Post('user/createGuard') + createGuard( + //Nombre, Apellidos, Correo electrónico, Cédula, Teléfono, Contraseña + @Body('dni') dni: string, + @Body('name') name: string, + @Body('last_name') last_name: string, + @Body('email') email: string, + @Body('phone') phone: number, + @Body('password') password: string, + @Body('user_type') user_type: string, + @Body('status') status: string, + @Body('date_entry') date_entry: Date, + ) { + return this.appService.createGuard(dni, name, last_name, email, phone, password, + user_type, status, date_entry); + } + @Post('user/createUser') createUser( @Body('dni') dni: string, diff --git a/api-gateway/src/app.service.ts b/api-gateway/src/app.service.ts index 4ede2579..8c88538d 100644 --- a/api-gateway/src/app.service.ts +++ b/api-gateway/src/app.service.ts @@ -50,6 +50,20 @@ export class AppService { ); } + createGuard(dni: string, name: string, last_name: string, email: string, phone: number + , password: string, user_type: string, status: string, date_entry: Date) { + const pattern = { cmd: 'createGuard' }; + const payload = { + dni: dni, name: name, last_name: last_name, email: email, phone: phone, + password: password, user_type: user_type, status: status, date_entry: date_entry + }; + return this.clientUserApp + .send(pattern, payload) + .pipe( + map((message: string) => ({ message })), + ); + } + allUsers() { const pattern = { cmd: 'findAllUsers' }; const payload = {}; diff --git a/servicio-usuarios/src/users/users.controller.ts b/servicio-usuarios/src/users/users.controller.ts index d65748ce..462a96e3 100644 --- a/servicio-usuarios/src/users/users.controller.ts +++ b/servicio-usuarios/src/users/users.controller.ts @@ -17,6 +17,11 @@ export class UsersController { return this.userService.create(user); } + @MessagePattern({ cmd: 'createGuard' }) + createGuard(@Payload() user: UserDocument) { + return this.userService.create(user); + } + @MessagePattern({ cmd: 'findAllUsers' }) findAll() { return this.userService.findAll(); diff --git a/web-ui/web-react/src/App.js b/web-ui/web-react/src/App.js index 83530986..2ee76365 100644 --- a/web-ui/web-react/src/App.js +++ b/web-ui/web-react/src/App.js @@ -30,6 +30,7 @@ import BlocksDemo from './templates/BlocksDemo'; import IconsDemo from './templates/IconsDemo'; import AdministradoresSistema from './components/AdministradoresSistema'; import AdministradoresComunidad from './components/AdministradoresComunidad'; +import GuardasSeguridad from './components/GuardasSeguridad'; import Crud from './pages/Crud'; import EmptyPage from './pages/EmptyPage'; @@ -165,6 +166,7 @@ const App = () => { {label: 'Dashboard', icon: 'pi pi-fw pi-home', to: '/'}, {label: 'Administradores del sistema', icon: 'pi pi-fw pi-id-card', to: '/administradoresSistema'}, {label: 'Administradores de comunidad', icon: 'pi pi-fw pi-id-card', to: '/administradoresComunidad'}, + {label: 'Guardas de seguridad', icon: 'pi pi-fw pi-id-card', to: '/guardasSeguridad'}, {label: 'Log in', icon: 'pi pi-fw pi-id-card', to: '/logIn'} ] }, @@ -320,6 +322,7 @@ const App = () => { + diff --git a/web-ui/web-react/src/components/GuardasSeguridad.js b/web-ui/web-react/src/components/GuardasSeguridad.js new file mode 100644 index 00000000..626f3faa --- /dev/null +++ b/web-ui/web-react/src/components/GuardasSeguridad.js @@ -0,0 +1,108 @@ +import React, { useEffect, useState } from 'react'; +import { InputText } from 'primereact/inputtext'; +import { Button } from 'primereact/button'; +import { DataTable } from 'primereact/datatable'; +import { Column } from 'primereact/column'; + +const GuardasSeguridad = () => { + + const [pokemones,setPokemones]=useState([]); + const [urlFetch,setUrlFetch]=useState('http://localhost:4000/user/findAdminSistema/'); + async function fetchP(){ + let nombres=await fetch(urlFetch, {method:'GET'}); + let pokemonesRes= await nombres.json(); + setPokemones(pokemonesRes.message); + console.log(pokemones); + } + useEffect(()=>{ + fetchP(); + },[]) + + function registrarAdmin() { + var data = { + dni: document.getElementById('identificacion').value, + name: document.getElementById('nombre').value, + last_name: document.getElementById('apellidos').value, + email: document.getElementById('correo_electronico').value, + phone: document.getElementById('telefono').value, + password: document.getElementById('correo_electronico').value, + user_type: "1", //1 es admin + status: "1" + }; + // console.log(data); + + fetch('http://localhost:4000/user/createAdminSystem/', { + cache: 'no-cache', + method: 'POST', + body: JSON.stringify(data), + headers: { + 'Content-Type': 'application/json' + } + }) + .then( + function (response) { + if (response.status != 201) + console.log('Ocurrió un error con el servicio: ' + response.status); + else + return response.json(); + } + ) + .then( + function (response) { + fetchP(); + } + ) + .catch( + err => console.log('Ocurrió un error con el fetch', err) + ); + } + + return ( +
+
+
+
Guardas de seguridad
+ + + + + + + +
+
+
+
+
Registro de un administrador del sistema
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+
+
+
+ + + ) +} + +export default React.memo(GuardasSeguridad); \ No newline at end of file From bb83aa148244b8fc34de0f324c0f49439ea81e3f Mon Sep 17 00:00:00 2001 From: Traym17 <51390112+Traym17@users.noreply.github.com> Date: Mon, 18 Jul 2022 21:33:36 -0600 Subject: [PATCH 2/3] Pruebas de cors --- api-gateway/package-lock.json | 1 + api-gateway/package.json | 1 + api-gateway/src/app.controller.ts | 3 +- api-gateway/src/app.service.ts | 4 +-- api-gateway/src/main.ts | 2 +- web-ui/web-react/package-lock.json | 22 +++++++++++++++ web-ui/web-react/package.json | 11 ++++---- .../src/components/GuardasSeguridad.js | 28 +++++++++++++------ 8 files changed, 55 insertions(+), 17 deletions(-) diff --git a/api-gateway/package-lock.json b/api-gateway/package-lock.json index 45818f0c..14bac898 100644 --- a/api-gateway/package-lock.json +++ b/api-gateway/package-lock.json @@ -12,6 +12,7 @@ "@nestjs/core": "^8.0.0", "@nestjs/microservices": "^8.4.7", "@nestjs/platform-express": "^8.0.0", + "cors": "^2.8.5", "reflect-metadata": "^0.1.13", "rimraf": "^3.0.2", "rxjs": "^7.2.0" diff --git a/api-gateway/package.json b/api-gateway/package.json index cdd17cfe..fb1d5eba 100644 --- a/api-gateway/package.json +++ b/api-gateway/package.json @@ -25,6 +25,7 @@ "@nestjs/core": "^8.0.0", "@nestjs/microservices": "^8.4.7", "@nestjs/platform-express": "^8.0.0", + "cors": "^2.8.5", "reflect-metadata": "^0.1.13", "rimraf": "^3.0.2", "rxjs": "^7.2.0" diff --git a/api-gateway/src/app.controller.ts b/api-gateway/src/app.controller.ts index ff3bfa32..7bcf7867 100644 --- a/api-gateway/src/app.controller.ts +++ b/api-gateway/src/app.controller.ts @@ -34,9 +34,10 @@ export class AppController { @Body('user_type') user_type: string, @Body('status') status: string, @Body('date_entry') date_entry: Date, + @Body('community_id') community_id:string ) { return this.appService.createGuard(dni, name, last_name, email, phone, password, - user_type, status, date_entry); + user_type, status, date_entry,community_id); } @Post('user/createUser') diff --git a/api-gateway/src/app.service.ts b/api-gateway/src/app.service.ts index 8c88538d..413b0737 100644 --- a/api-gateway/src/app.service.ts +++ b/api-gateway/src/app.service.ts @@ -51,11 +51,11 @@ export class AppService { } createGuard(dni: string, name: string, last_name: string, email: string, phone: number - , password: string, user_type: string, status: string, date_entry: Date) { + , password: string, user_type: string, status: string, date_entry: Date, community_id: string) { const pattern = { cmd: 'createGuard' }; const payload = { dni: dni, name: name, last_name: last_name, email: email, phone: phone, - password: password, user_type: user_type, status: status, date_entry: date_entry + password: password, user_type: user_type, status: status, date_entry: date_entry, community_id }; return this.clientUserApp .send(pattern, payload) diff --git a/api-gateway/src/main.ts b/api-gateway/src/main.ts index 3bea0f30..aba64268 100644 --- a/api-gateway/src/main.ts +++ b/api-gateway/src/main.ts @@ -4,6 +4,6 @@ const cors= require('cors'); async function bootstrap() { const app = await NestFactory.create(AppModule); await app.listen(4000); - app.use(cors()); + app.use(cors()) } bootstrap(); diff --git a/web-ui/web-react/package-lock.json b/web-ui/web-react/package-lock.json index 45064bbd..48c45103 100644 --- a/web-ui/web-react/package-lock.json +++ b/web-ui/web-react/package-lock.json @@ -17,6 +17,7 @@ "axios": "^0.19.0", "chart.js": "3.3.2", "classnames": "^2.2.6", + "cors": "^2.8.5", "primeflex": "3.1.0", "primeicons": "^5.0.0", "primereact": "7.2.0", @@ -5183,6 +5184,18 @@ "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" }, + "node_modules/cors": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/cosmiconfig": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.2.1.tgz", @@ -21869,6 +21882,15 @@ "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" }, + "cors": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "requires": { + "object-assign": "^4", + "vary": "^1" + } + }, "cosmiconfig": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.2.1.tgz", diff --git a/web-ui/web-react/package.json b/web-ui/web-react/package.json index 7c1031f7..00421d8f 100644 --- a/web-ui/web-react/package.json +++ b/web-ui/web-react/package.json @@ -12,12 +12,15 @@ "@fullcalendar/core": "^5.7.2", "@fullcalendar/daygrid": "^5.7.2", "@fullcalendar/interaction": "^5.7.2", - "@fullcalendar/timegrid": "^5.7.2", "@fullcalendar/react": "^5.7.0", + "@fullcalendar/timegrid": "^5.7.2", + "axios": "^0.19.0", "chart.js": "3.3.2", - "primereact": "7.2.0", + "classnames": "^2.2.6", + "cors": "^2.8.5", "primeflex": "3.1.0", "primeicons": "^5.0.0", + "primereact": "7.2.0", "prismjs": "1.9.0", "react": "^17.0.1", "react-app-polyfill": "^1.0.6", @@ -25,9 +28,7 @@ "react-router-dom": "^5.2.0", "react-scripts": "3.4.1", "react-transition-group": "^4.4.1", - "sass": "^1.32.8", - "axios": "^0.19.0", - "classnames": "^2.2.6" + "sass": "^1.32.8" }, "scripts": { "start": "react-scripts start", diff --git a/web-ui/web-react/src/components/GuardasSeguridad.js b/web-ui/web-react/src/components/GuardasSeguridad.js index 626f3faa..e3e05eb8 100644 --- a/web-ui/web-react/src/components/GuardasSeguridad.js +++ b/web-ui/web-react/src/components/GuardasSeguridad.js @@ -18,7 +18,7 @@ const GuardasSeguridad = () => { fetchP(); },[]) - function registrarAdmin() { + function registrarGuarda() { var data = { dni: document.getElementById('identificacion').value, name: document.getElementById('nombre').value, @@ -26,15 +26,27 @@ const GuardasSeguridad = () => { email: document.getElementById('correo_electronico').value, phone: document.getElementById('telefono').value, password: document.getElementById('correo_electronico').value, - user_type: "1", //1 es admin - status: "1" + user_type: "4", //4 es guarda + status: "1", + community_id:"62be68215692582bbfd77134" }; - // console.log(data); + var data2={ + dni: "98765", + name: "Danielito", + last_name: "Rodriguez", + email: "danirodriguez@gmail.com", + phone: 84664515, + password: "1203", + user_type: "2", + status: "4", + community_id:"62be68215692582bbfd77134" + } + console.log(data2); - fetch('http://localhost:4000/user/createAdminSystem/', { + fetch('http://localhost:4000/user/createGuard', { cache: 'no-cache', method: 'POST', - body: JSON.stringify(data), + body: JSON.stringify(data2), headers: { 'Content-Type': 'application/json' } @@ -73,7 +85,7 @@ const GuardasSeguridad = () => {
-
Registro de un administrador del sistema
+
Registro de un guarda de seguridad
@@ -95,7 +107,7 @@ const GuardasSeguridad = () => {
- +
From 537997bc408f2c858f522ce2c87c4710c314f4de Mon Sep 17 00:00:00 2001 From: Traym17 <51390112+Traym17@users.noreply.github.com> Date: Mon, 18 Jul 2022 22:28:56 -0600 Subject: [PATCH 3/3] Listar de guardas de seguridad --- api-gateway/package-lock.json | 11 +++++++++++ api-gateway/package.json | 1 + api-gateway/src/app.controller.ts | 8 ++++++-- api-gateway/src/app.service.ts | 10 ++++++++++ api-gateway/src/main.ts | 8 +++++++- servicio-comunidad-viviendas/package-lock.json | 1 - servicio-usuarios/package-lock.json | 1 + servicio-usuarios/package.json | 1 + servicio-usuarios/src/users/users.controller.ts | 6 ++++++ servicio-usuarios/src/users/users.service.ts | 4 ++++ web-ui/web-react/src/components/GuardasSeguridad.js | 3 ++- 11 files changed, 49 insertions(+), 5 deletions(-) diff --git a/api-gateway/package-lock.json b/api-gateway/package-lock.json index 14bac898..ffffe99e 100644 --- a/api-gateway/package-lock.json +++ b/api-gateway/package-lock.json @@ -12,6 +12,7 @@ "@nestjs/core": "^8.0.0", "@nestjs/microservices": "^8.4.7", "@nestjs/platform-express": "^8.0.0", + "@types/cors": "^2.8.12", "cors": "^2.8.5", "reflect-metadata": "^0.1.13", "rimraf": "^3.0.2", @@ -1883,6 +1884,11 @@ "integrity": "sha512-t73xJJrvdTjXrn4jLS9VSGRbz0nUY3cl2DMGDU48lKl+HR9dbbjW2A9r3g40VA++mQpy6uuHg33gy7du2BKpog==", "dev": true }, + "node_modules/@types/cors": { + "version": "2.8.12", + "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.12.tgz", + "integrity": "sha512-vt+kDhq/M2ayberEtJcIN/hxXy1Pk+59g2FV/ZQceeaTyCtCucjL2Q7FXlFjtWn4n15KCr1NE2lNNFhp0lEThw==" + }, "node_modules/@types/eslint": { "version": "8.4.3", "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.3.tgz", @@ -10109,6 +10115,11 @@ "integrity": "sha512-t73xJJrvdTjXrn4jLS9VSGRbz0nUY3cl2DMGDU48lKl+HR9dbbjW2A9r3g40VA++mQpy6uuHg33gy7du2BKpog==", "dev": true }, + "@types/cors": { + "version": "2.8.12", + "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.12.tgz", + "integrity": "sha512-vt+kDhq/M2ayberEtJcIN/hxXy1Pk+59g2FV/ZQceeaTyCtCucjL2Q7FXlFjtWn4n15KCr1NE2lNNFhp0lEThw==" + }, "@types/eslint": { "version": "8.4.3", "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.3.tgz", diff --git a/api-gateway/package.json b/api-gateway/package.json index fb1d5eba..78136508 100644 --- a/api-gateway/package.json +++ b/api-gateway/package.json @@ -25,6 +25,7 @@ "@nestjs/core": "^8.0.0", "@nestjs/microservices": "^8.4.7", "@nestjs/platform-express": "^8.0.0", + "@types/cors": "^2.8.12", "cors": "^2.8.5", "reflect-metadata": "^0.1.13", "rimraf": "^3.0.2", diff --git a/api-gateway/src/app.controller.ts b/api-gateway/src/app.controller.ts index 7bcf7867..8730ed02 100644 --- a/api-gateway/src/app.controller.ts +++ b/api-gateway/src/app.controller.ts @@ -1,10 +1,8 @@ import { Controller, Get, Post, Body, Param } from '@nestjs/common'; import { AppService } from "./app.service"; - @Controller() export class AppController { constructor(private readonly appService: AppService) { } - // #==== API Users @Post('user/createAdminSystem') createAdminSystem( @@ -79,6 +77,12 @@ export class AppController { allUsersAdminComunidad() { return this.appService.allUsersAdminComunidad(); } + @Get('user/findGuards/:community') + findGuardsCommunity( + @Param('community_id') community_id: string + ) { + return this.appService.findGuardsCommunity(community_id); + } @Get('user/find/:dni') findUser( diff --git a/api-gateway/src/app.service.ts b/api-gateway/src/app.service.ts index 413b0737..20bd90c9 100644 --- a/api-gateway/src/app.service.ts +++ b/api-gateway/src/app.service.ts @@ -105,6 +105,16 @@ export class AppService { ); } + findGuardsCommunity(community_id: string) { + const pattern = { cmd: 'findGuardsCommunity' }; + const payload = { community_id: community_id }; + return this.clientUserApp + .send(pattern, payload) + .pipe( + map((message: string) => ({ message })), + ); + } + inicioSesion(pEmail: string, pPassword: string) { const pattern = { cmd: 'loginUser' }; const payload = { email: pEmail, password: pPassword}; diff --git a/api-gateway/src/main.ts b/api-gateway/src/main.ts index aba64268..0a197e5f 100644 --- a/api-gateway/src/main.ts +++ b/api-gateway/src/main.ts @@ -3,7 +3,13 @@ import { AppModule } from './app.module'; const cors= require('cors'); async function bootstrap() { const app = await NestFactory.create(AppModule); + + app.enableCors({ + origin: 'http://localhost:3000', + methods: 'GET, PUT, POST, DELETE', + allowedHeaders: 'Content-Type, Authorization', + }); await app.listen(4000); - app.use(cors()) + //app.use(cors(enableCors)) } bootstrap(); diff --git a/servicio-comunidad-viviendas/package-lock.json b/servicio-comunidad-viviendas/package-lock.json index 22c95f9b..46dd3dd0 100644 --- a/servicio-comunidad-viviendas/package-lock.json +++ b/servicio-comunidad-viviendas/package-lock.json @@ -5,7 +5,6 @@ "requires": true, "packages": { "": { - "name": "servicio-comunidad-viviendas", "version": "0.0.1", "license": "UNLICENSED", "dependencies": { diff --git a/servicio-usuarios/package-lock.json b/servicio-usuarios/package-lock.json index e044c9d9..55f87407 100644 --- a/servicio-usuarios/package-lock.json +++ b/servicio-usuarios/package-lock.json @@ -16,6 +16,7 @@ "@nestjs/platform-express": "^8.0.0", "@nestjs/swagger": "^5.2.1", "buffer": "^5.7.1", + "cors": "^2.8.5", "crypto-browserify": "^3.12.0", "md5-typescript": "^1.0.5", "mongoose": "^6.4.1", diff --git a/servicio-usuarios/package.json b/servicio-usuarios/package.json index 453489ec..65b4ea6b 100644 --- a/servicio-usuarios/package.json +++ b/servicio-usuarios/package.json @@ -29,6 +29,7 @@ "@nestjs/platform-express": "^8.0.0", "@nestjs/swagger": "^5.2.1", "buffer": "^5.7.1", + "cors": "^2.8.5", "crypto-browserify": "^3.12.0", "md5-typescript": "^1.0.5", "mongoose": "^6.4.1", diff --git a/servicio-usuarios/src/users/users.controller.ts b/servicio-usuarios/src/users/users.controller.ts index 462a96e3..ba72ee15 100644 --- a/servicio-usuarios/src/users/users.controller.ts +++ b/servicio-usuarios/src/users/users.controller.ts @@ -32,6 +32,12 @@ export class UsersController { let dni = id['dni']; return this.userService.findOneByDNI(dni); } + + @MessagePattern({ cmd: 'findGuardsCommunity' }) + findGuardsCommunity(@Payload() community_id: string) { + let pcommunity_id = community_id['community_id']; + return this.userService.findGuardsCommunity(pcommunity_id); + } @MessagePattern({ cmd: 'updateUser' }) update(@Payload() user: UserDocument) { diff --git a/servicio-usuarios/src/users/users.service.ts b/servicio-usuarios/src/users/users.service.ts index b7071691..f4503498 100644 --- a/servicio-usuarios/src/users/users.service.ts +++ b/servicio-usuarios/src/users/users.service.ts @@ -70,6 +70,10 @@ export class UsersService { return this.userModel.find({ user_type: 1 }).exec(); } + //find admin del sistema + async findGuardsCommunity(pcommunity_id: string): Promise { + return this.userModel.find({ user_type: 4 }).exec(); + } //find admin de comunidad async allUsersAdminComunidad(): Promise { return this.userModel.find({ user_type: 2 }).exec(); diff --git a/web-ui/web-react/src/components/GuardasSeguridad.js b/web-ui/web-react/src/components/GuardasSeguridad.js index e3e05eb8..bc4ec2f8 100644 --- a/web-ui/web-react/src/components/GuardasSeguridad.js +++ b/web-ui/web-react/src/components/GuardasSeguridad.js @@ -7,7 +7,7 @@ import { Column } from 'primereact/column'; const GuardasSeguridad = () => { const [pokemones,setPokemones]=useState([]); - const [urlFetch,setUrlFetch]=useState('http://localhost:4000/user/findAdminSistema/'); + const [urlFetch,setUrlFetch]=useState('http://localhost:4000/user/findGuards/62be68215692582bbfd77134'); async function fetchP(){ let nombres=await fetch(urlFetch, {method:'GET'}); let pokemonesRes= await nombres.json(); @@ -46,6 +46,7 @@ const GuardasSeguridad = () => { fetch('http://localhost:4000/user/createGuard', { cache: 'no-cache', method: 'POST', + mode:'cors', body: JSON.stringify(data2), headers: { 'Content-Type': 'application/json'