Questions tagged [node-js]

100534 questions
1

votes
1

answer
1k

Views

How to do group_concat in select query in Sequelize?

I want to do GROUP_CONCAT in select query in sequelize here is my requirement what i want SELECT `group_name`, `description`, GROUP_CONCAT(`module_name`) FROM `group_access` GROUP BY `group_name` I want to write this type of query in sequelize. This is what i tried. groupAccess.findAll({ attributes:...
Vinit Singh
1

votes
1

answer
798

Views

stopping duplicate entry in dynamodb

I have a table called followProduct in Dynamodb and it has following strucure id - item id email - user email product - product id Whenever a user follows a product I am making an entry in the table. I am trying to stop duplicate entry and using the following code let params = { TableName: 'followPr...
Rishabh Jain
1

votes
2

answer
1.5k

Views

Difference between destructing export default and module.exports

I've been struggling to destruct my mongo object in another file, my object structure is like below. const env = { project: 'CRIBBBLE BACKEND', url: 'localhost', api: { url: 'https://api.dribbble.com/v1/', }, port: parseInt(process.env.PORT, 10) || 3000, mongo: database, }; export default env; But w...
Pedram marandi
1

votes
2

answer
2.3k

Views

How to add parameters to a GET request in node.js?

I am trying to access the different information from the following api:https://api.coinnest.co.kr/doc/public.html and stumped in trying to get data for all the different parameters for the /api/pub/ticker request Here is the code I have written so far, but i cant seem to get any different info for d...
WasabiCannon
1

votes
1

answer
1.1k

Views

Does NodeJS respect Docker virtualization and resource limits?

It is known that some applications aren't aware of Linux kernel isolation and virtualization features such as cgroups. This includes system utils like top, free and ps, but also platforms like Java. I've recently read an article which suggests that when running JVMs in Kubernetes, you should enforce...
Kir
0

votes
1

answer
7

Views

One out of two Document property not inserted in a mongoDB collection using: Mongoose and ExpressJS

A Nodejs server application gets Name and Age from an HTML form (with post method) and with the help of ExpressJS and Mongoose has to create a MongoDB document. That works but Age is not written in the document of the collection. Please help me to fix it. Here are the files with the code: personform...
user374324
1

votes
2

answer
442

Views

Parse text from HTML form inside table cell with Cheerio

I have a HTML table that looks like this: Text1 I want to get the value of the hidden input type named id_num. (In this example the value I want is 'ABCD123'). I tried to parse the code with cheerio like this: var $ = cheerio.load(body); $('tr').each(function(i, tr){ var children = $(this).children(...
Ford1892
1

votes
1

answer
964

Views

nvm not able to change the system node version using nvm

I am working on some remote linux server, where I want to set node v8.0.0. But it seems this has been set to use v0.10.35 and how much ever I try to use nvm use and set different node version, it doesn't work. Here are the simple code and output: [email protected]:$ nvm debug nvm --version: v0.32.0 $SHELL: /bin/...
kaounKaoun
1

votes
3

answer
861

Views

oauth2-server implementation nodejs

I'm trying to implement an OAUTH2 server in nodeJS, which allows client app to login users using my website(like login with google and in my case it is amazon alexa, which consumes this API/Client app). I tried using oauth2orise(https://www.npmjs.com/package/oauth2orize) and referred few links:- htt...
mahendra
1

votes
2

answer
73

Views

Why do I have to start some scripts with “npm start x” and others with “npm x” only?

In my package.json, I have the following part for script definition. 'scripts': { 'ng': 'ng', 'start': 'ng serve', 'build': 'ng build --prod', 'test': 'ng test', 'lint': 'ng lint', 'e2e': 'ng e2e' }, ... Whenever I want to run the app, I go npm start (which executes ng serve). I can also go npm run...
DonkeyBanana
1

votes
1

answer
2.3k

Views

Sequelize: passing Sequelize.op.in where

I am creating where dynamically for my model. I want to use in for multiple values. I read documentation and online and found this: Patient.findAll({ limit: limit, offset: offset, where: { [Sequelize.Op.in]: patientIds } }); I want to build where something like this: var filter = { [Sequelize.Op.in]...
Ashutosh
1

votes
3

answer
202

Views

How to load asynchronous database url and initiate database connection before express.js app starts?

I have configured the express.js app to run on AWS lambda. The database URL is stored and encrypted in the Amazon KMS service so if I want to use the URL then I have to decrypt the key using AWS KMS service. // imports import mongoose from 'mongoose'; import serverless from 'serverless-http'; // KMS...
sym
1

votes
1

answer
1.9k

Views

NodeJS, get return value from async await

I have an async await function that uses mongoose: const createModelB = async (id) => { try { let user = await User.findOne({id: id}); if (user) { let modelB = new ModelB({ user_id: user.id }); modelB = await scrum.save(); return modelB; } return null; } catch (err) { console.error(err); } return nu...
Mr.D
1

votes
1

answer
4.5k

Views

How to download an excel (xlsx) file using Angular 5 HttpClient get method with Node/Express backend?

I have an excel file in a directory on my nodejs server - Path to the file is - ./api/uploads/appsecuritydesign/output/appsecdesign.xlsx On click of a button in my Angular 5 component I am just trying to download the file using FileSaver. Below is my Angular component. Here the template code for th...
Aakash
1

votes
1

answer
2.2k

Views

readFileSync from an URL for Twitter media - node.js

I need to use an URL to import a media to Twitter. But I can't figure out how to use an URL without having to download the image, save it temporarily on the server and deleted after... I'm using Google Cloud to store the images that's why I can't access it directly. That's what I'm trying to do : va...
Phil
1

votes
2

answer
225

Views

How to use Typescript as compiler in node-migrate

To start, here's my migration script: const bluebird = require('bluebird'); const mongoose = require('mongoose'); mongoose.Promise = bluebird; mongoose.connect('mongodb://localhost:27017/app', { useMongoClient: true }); const schema = { uid: { type: String, }, parentID: { type: String...
Christopher Santos
1

votes
2

answer
2.2k

Views

CORS 'Allow-Credentials' Nodejs/Express

My project is running on Node with an Express backend. I'm trying to query my Arango database clientside with Arangojs. ArangoDB is running on Docker on Digital Ocean. I have no issues querying my database serverside, however I get the following error on page load: Failed to load http://0.0.0.0:8529...
jayf93
1

votes
2

answer
739

Views

Ramda map and filter in one loop

const R = require('rambda') export const test = () => { const data = [1, 2, 3, 4, 5, 6, 7, 8] const filter = no => no > 5 const map = no => no * 100 // looping 2 times return data .filter(filter) .map(map) // wird 1 loop return data.reduce((data, no) => { if (!filter(no)) return data data.push(map(n...
user2386092
1

votes
2

answer
1.9k

Views

How to detect if a message is edited?

I am intending for my bot to allow only 'ew' to be sent in chat. I have resolved majority of the work-arounds, however, there is one I can't resolve independently. When someone posts 'ew' in chat and then edits the message to something else, it remains like that without being deleted. How could I re...
Brandon
1

votes
1

answer
260

Views

Firebase deploy get ID with onCreate for push notifications

I'm creating an iOS app and sending notifications. I'm trying to get an id from Firebase but the code below doesn't work. exports.pushNotifications = functions.database.ref('/message/{messageId}') .onCreate((snap, context) => { var messageId = event.params.uid; . . . I tried this code from the docum...
coonie
1

votes
3

answer
5.2k

Views

Angular Template parse errors: The pipe could not be found

app.module.ts import { BrowserModule } from '@angular/platform-browser'; import { ErrorHandler, NgModule } from '@angular/core'; import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular'; import { SplashScreen } from '@ionic-native/splash-screen'; import { StatusBar } from '@ionic-nat...
shah rushabh
1

votes
2

answer
2.4k

Views

Create with Include Sequelize

recently I discovered this on the sequelize documentation where you can create using include. Now I trying to do it on my program but only creates the records of the 'parent' model and not for the children. This is my model and my controller. var MainMenu = sequelize.define('MainMenu', { Name: { ty...
Ellebkey
1

votes
1

answer
281

Views

Response for preflight has invalid HTTP status code 401 - Testing

so i'm using nodejs to access an API ( league of legend api ) from my server, i tested the route that access the api using httpie ( a simple http client) and everything is working without any issue. when i wanted to write tests for my api using Jest + supertest, and when i tested the route that acce...
karim
1

votes
1

answer
665

Views

Firebase doesn't deploy. ERROR SELF SIGNED CERTIFICATE

I've been following the tutorial on how to apply Dialoglflow to an app... https://developers.google.com/actions/dialogflow/first-app#deploy_the_fulfillment On the section BUILD FULFILLMENT, the error occurs. I've installed the latest node.js, python and installed npm on the directory. Yet the follow...
1

votes
2

answer
382

Views

NestJS - Injected service is undefined in the constructor

As per the documentation, I inject a service in a controller's constructor, but it turns out as undefined. processScraped.controller.ts import { Controller, Post, Body } from '@nestjs/common'; import { ProcessScrapedService } from './processScraped.service' console.log(`\nController - ProcessScraped...
Jeremy Thille
1

votes
3

answer
442

Views

How do I escape % in Knex where like query?

I'm using knex to generate my SQL queries. In knex documentation, it shows this knex('users').where('columnName', 'like', '%rowlikeme%') Now in my application, I did this: function search(term) { term = '%' + term + '%'; knex('table').where('description', 'like', term); // ... } How can I escape % s...
Jun
1

votes
2

answer
518

Views

two phase commit in nodeJS application

I am currently working on a nodeJS application that will soon need to write simultaneously on two PostgreSQL databases. This is meant for redudancy purposes: the writing operations must be made in the same time on both databases, or rollbacked if there is anything wrong with one of the databases. In...
Pikuni
1

votes
1

answer
301

Views

Is there any way to run Node.js in a <script> tag?

I would like to run Node.js in my webpage, the same way that you would with PHP or ASP.NET. The reason for this is I would like to use require()'d modules from NPM in my browser javascript, however vanilla JS doesn't seem to support this. Is there any way I can run Node.js in my tags? If not, would...
Thomas Jowsey
1

votes
1

answer
233

Views

TypeError: callback.apply is not a function after allowDiskUse

I have a collection having 1Million documents... I have passed the option for allowDiskUse and now it is throwing error TypeError: callback.apply is not a function I have searched for this but could get the solution... Please help const pictures = await Picture.aggregate([ { $sort: { createdAt: -1 }...
Anthony Winzlet
1

votes
1

answer
423

Views

Dialog api v2 - Unexpected error while acquiring application default credentials: Could not load the default credentials

i am trying to implement a chat bot application with google dialog flow. i was fallowing this github tutorial https://github.com/dialogflow/dialogflow-nodejs-client-v2 to implement api. this is my code var express = require('express'); var router = express.Router(); const projectId = 'my-project-id'...
pavithra rox
0

votes
2

answer
31

Views

How to pass multiple parameters as an object in url using react

I am trying to pass multiple parameters to my api (Koa) via URL (from ReactJS using Axios) to post data to my db. This code is working, but I am wondering if there is an easier way to pass data instead of typing out each value to insert into the database? I am adding an advising time to my db as suc...
gad74
1

votes
1

answer
26

Views

How to communicate between two containers using docker

I'm facing an issue to access one container route in another container. For example i have two micro services called user-service and api-gateway. I'm trying to access user-service route in api-gateway. My api-gateway file could be like below const userServiceProxy = httpProxy(http://localhost:8093...
Sasi Rekha
0

votes
0

answer
14

Views

Eslint throws exception when multiple variables are declared as global

Here is code for my js file import { Selector } from 'testcafe' /* global fixture:true, test:true */ fixture`index` .page`http://localhost:8080` test('Index Page Loads', async t => { await t // Check for h1 tag .expect(Selector('#root h1').innerText).eql('Hello') }) When I run lint it throws except...
Sandy
0

votes
0

answer
4

Views

How to change property of newly created collection on click

I am creating a new collection from current schema with same properties. I am using nodemailer to verify email by setting a schema key to value true upon clicking the link. It is happening successfully if changing value of current schema from this code:- router.get('/verify',function(req,res){ con...
NoobCoder
1

votes
3

answer
645

Views

What does mean by node module wrapper function in node

i would like to know about, what does mean by module wrapper function and what does it do to my code ? (function (exports, require, module, __filename, __dirname) { });
yasiru
1

votes
1

answer
70

Views

DynamoDB query equivalent to “WHERE author IN [..]”?

Given the following data structure; { 'author': 'USERNAME', 'caption': 'Caption of video', 'createdAt': 1531260177951, 'id': '03290200-848d-12e8-a1b5-bb9570f524f1', // Current primary key 's3Bucket': 's3-bucket-name', 's3Key': 'USERNAME/1521260163051.mp4', 'updatedAt': 1531260177951 } I am trying to...
Automatico
1

votes
3

answer
1.1k

Views

Building Angular project lead to heap out of memory

When trying to build an Angular project on a Linux server with -aot flag, I get an error. I tried upgrading my instance to a higher CPU core, more RAM and turn on a SWAP partition but still the error just occur faster. Here's while trying to build from terminal along with the command with the flags...
user2280167
1

votes
3

answer
2.5k

Views

How to avoid being detected as bot on Puppeteer and Phantomjs?

Puppeteer and PhantomJS are similar. The issue I'm having is happening for both, and the code is also similar. I'd like to catch some informations from a website, which needs authentication for viewing those informations. I can't even access home page because it's detected like a 'suspicious activit...
1

votes
2

answer
341

Views

Node.js await catch not returning

I am busy working with some code that is responing in an unexpected way (to me). It involves handling Node.js promise exceptions. I have the following function modified so that all it does is fail function asynFunc() { return new Promise(function(res, rej) { rej('GENERIC ERROR'); }); } The problem c...
TheLovelySausage
1

votes
1

answer
451

Views

How to connect WIX template with 3rd party REST APIs?

I created a simple web site using WIX platform. (https://www.wix.com/). I have some simple forms. Like customer registration and package management. All the UI part is done. And I have a Node.JS server to manage customers and packages. API is 100% done. Now I need to connect WIX template with my NOd...
Chanaka De Silva

View additional questions