express

NodeJS Postgres error getaddrinfo ENOTFOUND

六月ゝ 毕业季﹏ 提交于 2020-05-23 08:20:08
问题 I use pg://user:pass@localhost:port/table for connecting to my AWS database. When I use localhost, the app works fine, but when I try to connect the AWS server it falls apart. Even a simple connection code gives me this error. The database name is people and it's running on port 8080 but in this error it's showing 5432 even if I declare the correct port number in the conString. Error: getaddrinfo ENOTFOUND people people:5432 at errnoException (dns.js:26:10) at GetAddrInfoReqWrap.onlookup [as

UnhandledPromiseRejectionWarning: MongooseServerSelectionError

独自空忆成欢 提交于 2020-05-20 07:37:06
问题 I am following these tutorials as I wanted to start with MongoDB and the MERN stack: https://medium.com/@beaucarnes/learn-the-mern-stack-by-building-an-exercise-tracker-mern-tutorial-59c13c1237a1 https://www.youtube.com/watch?v=7CqJlxBYj-M Everything was fine until my connection with the database failed. I checked the username/password million times, I copied and pasted the original in case I had some syntax error. This is the error: (node:10156) UnhandledPromiseRejectionWarning:

UnhandledPromiseRejectionWarning: MongooseServerSelectionError

天涯浪子 提交于 2020-05-20 07:37:05
问题 I am following these tutorials as I wanted to start with MongoDB and the MERN stack: https://medium.com/@beaucarnes/learn-the-mern-stack-by-building-an-exercise-tracker-mern-tutorial-59c13c1237a1 https://www.youtube.com/watch?v=7CqJlxBYj-M Everything was fine until my connection with the database failed. I checked the username/password million times, I copied and pasted the original in case I had some syntax error. This is the error: (node:10156) UnhandledPromiseRejectionWarning:

MongoDB does not refresh data automatically?

流过昼夜 提交于 2020-05-18 04:46:26
问题 I use MEAN stack for developing. And after adding some data to MongoDB, the new data is available in front-end only after restarting NodeJS server. There is any way to update MongoDB data 'online'? This is my API (Node.js): var express = require('express'); var mongoose = require('mongoose'); var router = express.Router(); mongoose.connect('mongodb://localhost/vt'); var Video = mongoose.Schema({ idv: String, thumbnail: Number, aud : String, title : String, description : String }); var db; var

MongoDB does not refresh data automatically?

点点圈 提交于 2020-05-18 04:41:07
问题 I use MEAN stack for developing. And after adding some data to MongoDB, the new data is available in front-end only after restarting NodeJS server. There is any way to update MongoDB data 'online'? This is my API (Node.js): var express = require('express'); var mongoose = require('mongoose'); var router = express.Router(); mongoose.connect('mongodb://localhost/vt'); var Video = mongoose.Schema({ idv: String, thumbnail: Number, aud : String, title : String, description : String }); var db; var

json post method format

纵饮孤独 提交于 2020-05-17 08:50:36
问题 I got following format when i send post request from postman. { ID:"66", Blod:"test", Allergic:"no", Chronic:"no" } But i got this format when i send post request using react app post method. [Object: null prototype] { '{ "ID":"123456789", "Blod":"22334445", "Allergic":"6677788", "Chronic":"3445566"}': '' } please help me how can I got the same format of postman to insert data correctly. this is my method from react app uisng axios module : submithandler=(e)=>{ e.preventDefault(); axios.post(

Node js express how to create new datatable once another one is full

强颜欢笑 提交于 2020-05-17 08:49:29
问题 I'm working on a project right now that will populate a MySQL database from a script I will be running on port 3000. The script looks something like this: curl localhost:3000/register?name=bob\&width=13.970000\&time=0 curl localhost:3000/wheels?left=0.000000\&right=0.000000\&time=0 --cookie "USER=bob" curl localhost:3000/echo?dist=9.220000\&time=10 --cookie "USER=bob" curl localhost:3000/line?l1=1\&l2=1\&l3=1\&time=20 --cookie "USER=bob" curl localhost:3000/other?ir=0\&time=30 --cookie "USER

How do I count all the documents in a collection and use the cont in a controller, with MongoDB and Express.js?

大憨熊 提交于 2020-05-17 07:45:26
问题 I am working on a blogging application (click the link to see the GitHub repo) with Express, EJS and MongoDB. Trying to paginate the posts I did the following, in the controller: exports.getPosts = (req, res, next) => { const perPage = 5; const currPage = req.query.page ? parseInt(req.query.page) : 1; let postsCount = 0; const posts = Post.find({}, (err, posts) => { postsCount = posts.length; let pageDecrement = currPage > 1 ? 1 : 0; let pageIncrement = postsCount >= perPage ? 1 : 0; if (err)

Jest Express testing middleware with arguments

主宰稳场 提交于 2020-05-17 07:25:17
问题 I'm pretty new to node and this is my first time unit testing an app. I'm doing well with Jest faking the request with Jest function as below // Create a fake request const mockRequest = (sessionData, body) => ({ session: { data: sessionData }, body }); // Create a fake response const mockResponse = () => { const res = {}; res.status = jest.fn().mockReturnValue(res); res.json = jest.fn().mockReturnValue(res); return res; }; const mockNext = () => { const next = jest.fn(); return next; }; So I

nodemailer always sending the same response, res.send() not working

☆樱花仙子☆ 提交于 2020-05-17 07:01:46
问题 I'm trying to send a custom response if the email sending fails or succeeds... server router .post('/send-email', function (req, res) { let senderEmail = req.body.email; let message = req.body.message; let transporter = nodemailer.createTransport({ host: 'mail.domain.com', port: 25, secure: false, auth: { user: "contact@domain.com", pass: "password" }, tls: { secure: false, ignoreTLS: true, rejectUnauthorized: false } }); let mailOptions = { from: senderEmail, to: 'contact@domain.com',