3
respostas

Erro quando executo no navegador

Estou com Windows 10 pro.

C:\Users\marcio-silva\Desktop\api-windows>npm start

alurapic@1.0.0 start C:\Users\marcio-silva\Desktop\api-windows node server.js

Servidor escutando na porta: 3000 Users { user_id: 1, user_name: 'flavio', user_email: 'flavio@alurapic.com.br', user_password: 123, user_full_name: 'Flávio', user_join_date: '2018-04-12 20:24:19' } Users { user_id: 2, user_name: 'almeida', user_email: 'almeida@alurapic.com.br', user_password: 123, user_full_name: 'Almeida', user_join_date: '2018-04-12 20:24:19' } Users { user_id: 3, user_name: 'calopsita', user_email: 'calopsita@alura.com.br', user_password: 12345678, user_full_name: 'Calopsita do Agreste', user_join_date: 1529952323485 } Users { user_id: 4, user_name: 'alura', user_email: 'alura@alura.com.br', user_password: 12345678, user_full_name: 'Alura', user_join_date: 1530036414732 }

#################################### No token is send by the the application

####################################

#################################### Listing photos C:\Users\marcio-silva\Desktop\api-windows\node_modules\sqlite3\lib\trace.js:27 throw err; ^

TypeError: Cannot read property 'map' of undefined at Statement.db.all (C:\Users\marcio-silva\Desktop\api-windows\app\infra\photo-dao.js:55:41) --> in Database#all('\n SELECT p.*,\n (SELECT COUNT(c.commentid) \n FROM comment as c \n WHERE c.photo_id = p.photo_id\n ) as comments, \n\n (SELECT COUNT(l.like_id) \n FROM like as l \n WHERE l.photo_id = p.photo_id\n ) as likes \n FROM photo AS p\n JOIN\n user AS u ON p.user_id = u.user_id\n WHERE u.user_name = ?\n ORDER BY p.photo_post_date DESC\n ;\n ', [ 'flavio' ], [Function]) at Promise (C:\Users\marcio-silva\Desktop\api-windows\app\infra\photo-dao.js:35:22) at new Promise () at PhotoDao.listAllFromUser (C:\Users\marcio-silva\Desktop\api-windows\app\infra\photo-dao.js:34:16) at api.list (C:\Users\marc

3 respostas

Oi Marcio, tudo bem? Também estou no Windows 10 e não tive esse problema. Em que momento isso acontece? Na hora da requisição é isso?

Oi Wanderson!!!

o serviço no cmd sobe e mostra os dados. Quando eu executo o url de consulta pelo navegador (http://localhost:3000/flavio/photos) é que gera o erro no serviço. conforme abaixo: Listing photos C:\Users\marcio-silva\Desktop\api-windows\node_modules\sqlite3\lib\trace.js:27 throw err; ^

TypeError: Cannot read property 'map' of undefined at Statement.db.all (C:\Users\marcio-silva\Desktop\api-windows\app\infra\photo-dao.js:55:41) --> in Database#all('\n SELECT p.*,\n (SELECT COUNT(c.commentid) \n FROM comment as c \n WHERE c.photo_id = p.photo_id\n ) as comments, \n\n (SELECT COUNT(l.like_id) \n FROM like as l \n WHERE l.photo_id = p.photo_id\n ) as likes \n FROM photo AS p\n JOIN\n user AS u ON p.user_id = u.user_id\n WHERE u.user_name = ?\n ORDER BY p.photo_post_date DESC\n ;\n ', [ 'flavio' ], [Function]) at Promise (C:\Users\marcio-silva\Desktop\api-windows\app\infra\photo-dao.js:35:22) at new Promise () at PhotoDao.listAllFromUser (C:\Users\marcio-silva\Desktop\api-windows\app\infra\photo-dao.js:34:16) at api.list (C:\Users\marcio-silva\Desktop\api-windows\app\api\photo.js:21:14) at npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! alurapic@1.0.0 start: node server.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the alurapic@1.0.0 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\marcio-silva\AppData\Roaming\npm-cache_logs\2018-10-29T19_12_45_199Z-debug.log

C:\Users\marcio-silva\Desktop\api-windows>

Hm, estranho, você baixou a versão da API específica para o Windows? Lá na explicação tava bem claro que se usamos Windows, deveríamos baixar a versão já pronta.