node.js

  1. S

    Access URL in promise each

    I am using Bluebird.js and request-promise NPM module. I want to access promise URL or item.transactionID as in the code below. I try to find many things but failed to work How can we achieve this. paymentIDArray.forEach(item => { let p = rp({ uri: API +...
  2. A

    Regular epxression (sass variables)

    (Node.js) I have to match all Sass variables from file. But I can have variables and mixins in one file. I need to update regular epxression to not match a variables from mixin directive or from mixin / function content (nested). So only: $test: true; $white: #fff !default; $sizes: (25...
  3. H

    Update elastic search doc field value for specific fields in all documents

    I have documents like this. { "a":"test", "b":"harry" }, { "a":"" "b":"jack" } I need to update docs with field a==""(empty string) to default value say null in all documents for a given index. Any help is appreciated. Thanks
  4. P

    KnexJS raw query in migration

    I have a problem with the following migration in KnexJS, working with PostgreSQL: exports.up = (knex) => { knex.raw('CREATE EXTENSION IF NOT EXISTS "uuid-ossp"'); return knex.schema.createTable('car_brands', (table) => {...
  5. T

    Error - expressSessionMiddleware is not a function

    I'm trying to use express-socket.io-sessions to sockets with the users' sessions, but I keep getting this error when I try add the middleware. Here is my code: var express = require('express'); var socket = require('socket.io'); var sharedSession = require("express-socket.io-session")...
  6. K

    Extracting creation of a mongoose model out of server file

    I'm currently building a generic express API and I'm finding it difficult to extract code from my server.js file I have the following in my server.js file app.post('/parser', (req, res) => { var todo = new Todo({ text: req.body.text, }); todo.save().then((doc) => { res.send(doc)...
  7. I

    Convert timestamp from timezone to UTC timestamp?

    I am receiving a timestamp from a third-party API, that looks like: 1540388730994. However, I have been informed that this timestamp is in 'Europe/Amsterdam' timezone. I need to convert this timestamp to UTC, as we store all our dates in UTC. How is this possible in JavaScript? So far I have...
  8. A

    Unable to make my script keep clicking on a button

    I've created a script using node.js in association with puppeteer to click on more button located at the bottom of a webpage to dig out all the headlines from it's landing page. The thing is when I execute my script, It only clicks once and then quits. How can I keep clicking on that button...
  9. P

    Where to place error handler middleware in Express?

    I've just finished my middleware handler error.js as follow. I intend send error message based on http code. var HttpStatus = require('http-status-codes'); function errorHandler(err, req, res) { // Set locals, only providing error in development res.locals.message = err.message...
  10. M

    MongoDB & Mongoose query returns null for aggregate $or search with non-matching field, returns individual searches or with undefined value omitted

    I'm a bit confused by the behavior I'm seeing in a Mongoose/MongoDB query, as it seems that the $or operator is being treated as an $and I have the following Collection Document that I am querying for: { "_id": { "$oid": "5bd0d709ff8eef5d5325090f" }, "audienceTrackingID"...
  11. K

    Parse geometry object to wkt by node.js

    This is my postgresql table: create table scheduled_locations ( id uuid not null, device_id text not null, user_id uuid, created_date date, st_astext geometry not null constraint scheduled_locations_idkey primary key ); alter table...
  12. E

    How to prevent “npm install” change package.json

    I have a Maven project where I execute npm install in build with the com.github.eirslett frontend-maven-plugin plugin. My problem is that after the build, git says me that the package.json has been changed, although when I check the diff (in IntelliJ) it says Contents are identical. If i run...
  13. A

    Foursquare Api return just 1 result on `venue/photos` endpoint with userless authentication

    The result I get from venue/photos has different with the User Authentication. In the first one I just receive one result (one photo) in the result but in the the second one it return normal result that I expected. --userless authentication--...
  14. H

    How to access requested body from another function with async/await?

    Sorry for the generic title. I'm pretty new to nodejs as well as the idea of async/await. So I have an express app, which makes an HTTP get request as a callback function. The callback function gets the body object, and returns it to getBody function. But when I try to assign getBody to a...
  15. J

    NodeJS: Query Database Command with Loop condition

    I want to run a PostgreSQL database query command with condition OR to filter object by an ID Array. var id_arr = [1, 2, 3] Result I want to get: SELECT * FROM auth_user WHERE id = 1 OR id = 2 OR id = 3 I tried but it gets syntax error: var querydb = `SELECT * FROM auth_user WHERE ` + for...
  16. S

    If statement running after function being called

    I'm setting up a mailer to send an email to the relevant recipient about some details of an appointment request. I'm having an issue where the IF statement that runs to decide who the necessary recipient should be is running after the email transporter and is giving me an error saying that no...
  17. F

    Promise in Promise function: Can't push data into Array

    I am using sequelizeJS. I have a Promise in Promise function. I want to make a Promise function to get data, then push this data into Array and return this Array. I tried with this code but it's not success. function sequelize_conversation (conversation_id, req) { return new Promise((resolve...
  18. G

    How to make my website avalible on local network

    I'm currently working on my website which is running on nodejs usining expressjs, and everything is working fine. However I want to test my website from other devices, for example from my phone or other computer, which are connected to the same wi-fi. How am I supposed to do it? Thank you in...
  19. L

    How to set a Loopback nodeJS backend on Apache HTTP server running on CentOS

    I've moved the backend (nodeJs+Loopback) of my application on a server CentOS. When I run it, it's listening on "localhost:3000". If I type "curl http://localhost:3000" while I'm on the server's terminal I get a response. When I try to call the application from remote, I use the real IP address...
  20. K

    Nested queries in MYSQL and nodejs Async Issue

    I want to execute an sql query for every row of another query so i wrote a function like export function getLocations(req, res) { let appData = []; const database = new Database(); database.query('select * from districts') .then(rows => { rows.forEach(row => { const...
Top