Hi,I'm new to node and hope somebody can help me.I'm trying to return some Json from 2 SQL queries and one forEach loop. But I'm lost in the scope or in the call back hell :)app.get('/exercises/by_day/:day', (req, res, next ) => { const day = parseInt(req.params.day); let data = []; pool.query('SELECT id, title, img_url FROM exercise WHERE day = $1 ORDER BY title', [day], (error, results) => { if (error) { next(error); } results.rows.forEach(row => { // query check second table if the timestamp was today pool.query('SELECT count(id) as cnt FROM set WHERE set.exercise_id = $1 AND created_at >= now()::date', [row.id], (error, results) => { if (error) { next(error); } row.training_today = (results.rows[0].cnt > 0); data.push(row); }); }); data = results.rows; }); res.status(200).json(data); });
Submitted October 01, 2019 at 07:59PM by 23hurra
Tuesday, 1 October 2019
Nodejs Expressjs MongoDB Ready-to-use API Project Structure
Hello Everyone,I have created a boilerplate application for API development built with Nodejs, ExpressJs, MongoDB.Checkout: Nodejs Expressjs MongoDB Ready-to-use API Project StructureAny feedback suggestions are much appreciated. Pull requests are welcome.Have a nice day!
Submitted October 01, 2019 at 07:22PM by maitraysuthar
Submitted October 01, 2019 at 07:22PM by maitraysuthar
Cron a task that Download files and showes progress using FTP
Hey guys,i have a task in which to download files from server to another using FTP "With sending the state the file progress to an event"in which A front-end at the end shows files being downloading with pregress state of file,now am using this package of node :https://github.com/mscdex/node-ftpconnection to ftp,download the file gust like node-ftp documentationwith the usage of progress-stream to stream progress,as when i download the file i pipe the streamso evenutally it looks like thisstream.pipe(str).pipe(dest) where the stream is the fileand str is progress-stream with alot of setup so i can emit to event which the front end will listen and also generate anaysis from the packet of datathe Problem is i want to set this in infinite loop which runs every 5minuteswhen i use set interval or node-cron it doesnt workwhat i am missing ?please help?
Submitted October 01, 2019 at 04:55PM by cw4i
Submitted October 01, 2019 at 04:55PM by cw4i
Building A 16-Bit Virtual Machine in JavaScript Ep. 001
https://www.youtube.com/watch?v=fTBwD3sb5mw
Submitted October 01, 2019 at 01:59PM by FrancisStokes
Submitted October 01, 2019 at 01:59PM by FrancisStokes
How to deploy a Node Application and Database to Heroku
https://bolajiayodeji.hashnode.dev/how-to-deploy-a-node-application-and-database-to-heroku-ck132inhz004kqns1mo2ixtph
Submitted October 01, 2019 at 02:01PM by pmz
Submitted October 01, 2019 at 02:01PM by pmz
GitHub - vanderkilu/pollr: a minimal full-stack voting/poll app in node.js and vue.js
https://github.com/vanderkilu/pollr
Submitted October 01, 2019 at 02:02PM by pmz
Submitted October 01, 2019 at 02:02PM by pmz
ETIMEDOUT debugging?
I keep running into a situation where I’m testing an endpoint on my private network in postman, and it works fine. However, when I literally export the node/request code for the api request from postman and paste into my node app to run, it times out.So it’s the exact same api request, literally the payload was created in postman (where the request completes successfully) but it times out in node.Why? I’ve tried with request and native http with the same result.It makes no sense, both requests coming from the same ip/machine the only difference is one request comes from node one comes from postman. Node has no specific proxy or anything set either, neither does postman.Any ideas on why this could be happening?
Submitted October 01, 2019 at 01:09PM by jmackhh
Submitted October 01, 2019 at 01:09PM by jmackhh
Subscribe to:
Posts (Atom)