Issue I used the following code in order to get the response from the request, but I got an special result that I don’t know: import { Injectable } from ‘@nestjs/common’; import { HttpService } from ‘@nestjs/axios’; @Injectable() export class
Continue readingCategory: Node.js
Mongoose – session abortTransaction is not rolling back
Issue I don’t know what I’m missing but in the block catch session.abortTransaction() not rolling bak anything. I purposely used throw new Error("Error message") after the creation of a user to land in the catch block to trigger the session.abortTransaction()
Continue readingWhy do simple objects not log consistently in different environments?
Issue It would really help debugging if all environments just logged the same content consistently! I am having a problem being able to just log the correct contents across different IDEs and browsers. After reading various other posts (e.g. here),
Continue readingShow last inputed value in ejs from sql
Issue I want to Show last inputted value in Ejs from mySql, this in my code js router.get(‘/forming’,showForm); function showForm(req, res, next) { console.log("test1"); var getQuery = "SELECT tableone, mksa FROM myDataBase ORDER BY id DESC LIMIT 1"; let query
Continue readingQuery mongoose for every single element in array
Issue I want to query mongoose for every single element in an array (which itself is also result of a query to mongoose) and append the result to each array element respected and return the array: Service.find(query) .then((servicesList) => {
Continue reading"EPERM: operation not permitted, unlink 'C:\\Users\\<user>\\node_modules\\bufferutil\\prebuilds\\win32-ia32\\node.napi.node'"
Issue I’m trying npm i @solana/web3.js but cant due to the EPERM error. I tried changing the prefix in config, reinstalling Node, updating NPM and Yarn but nothing worked. Solution Cache clean and npm update to the latest with force
Continue readingUse return value in a .map after performing request.get
Issue So basically, due to the security, I need to convert image (from the url) to the base64. So far I have two functions. One function is converting the image from the url to the Base64 and the other one
Continue readingUnexpected token 'react' when using react-moralis
Issue I was able to install the package for react-moralis without any issues. When trying to import from the package I receive an "unexpected token failed to compile" syntax error. The simple code is this import { Moralis} from react-moralis
Continue readingNodeJs callback and parameters
Issue I came across this piece of code which needs some clarification. http://expressjs.com/en/guide/writing-middleware.html#:~:text=The%20next%20%28%29%20function%20is%20not%20a%20part,%E2%80%9Cnext%E2%80%9D.%20To%20avoid%20confusion%2C%20always%20use%20this%20convention. Refer section : "Configurable middleware" How is it possible that "req", "res" and "next" can be referred inside the exported function directly ? I mean neither the
Continue readingI am getting an error "Error: User validation failed" in MongoDB
Issue I am getting an error after trying to use the POST method through postman to register a user. I have created a simple Schema for the register route. Error: Error in register: Error: User validation failed: password: Cast to
Continue readingUsing environment variables in Node and Jest
Issue I have a NodeJS app. For a long time I’ve been using Mocha to run tests. I simply had a package.json like "dev": "node index –env=dev", "start": "node index", "test": "mocha ‘./test/**/*.spec’ –env=dev" Now I am switching to Jest
Continue readingInteraction Fails from Discord slash commands
Issue I need a bit of help with my code, I don’t get any errors except This Interaction Failed in Discord. The code I am using for slash commands: name: "random", description: "Random Message", options: [], async execute(_bot, say, interaction)
Continue readingESP32-CAM fastest way to stream video output to nodejs server with socketIO
Issue I would like to stream video camera from ESP32-CAM to web browser. To do so, I use a nodejs server (to broadcast video and serve html) and SocketIO to communicate (between ESP32-CAM -> nodejs and nodejs -> web browser).
Continue readingWhen does a Sequelize (ORM) instance method need `sequelize.` to refer to a different model and when not?
Issue Suppose inside a model you have the following Sequelize instance method: const Admins = require("./admin"); Organization.prototype.getAdmins = function () { // option 1 return Admins.findAll({ where: { organization_id: this.getDataValue("id") } }); // option 2 return sequelize.Admins.findAll({ where: { organization_id:
Continue readingBuilding a Node app should I use App Engine or Google Cloud Run?
Issue I am creating a Node app it has express, swagger and Agenda for running scheduled Jobs. What is the best way to deploy it in GCP. Should I use App Engine or Cloud run. From what I understand in
Continue readingNode express path hash anchor
Issue I currently have the following url structure in my Node application: http://localhost:3000/#record_2 Clicking on a link like the above will scroll the webpage to the element with the matching id of record_2. But I need extra information which can
Continue readingReplace word and count the total number of replace word in nodejs
Issue I am trying to replace word from a file with counting the total number of replaced word.how can I do it . This was my approach: var fs = require(‘fs’) var counter = 0; fs.readFile(‘test.txt’, ‘utf8’, function (err,data) {
Continue readingUse data in all components in react
Issue I want to get data and update it like this index.js import React from "react"; import ReactDOM from "react-dom/client"; import App from "./App"; const data = [ { id: 1, name: "Pansy Rolling", email: "prolling0@tinyurl.com", }, { id: 2,
Continue readingI am building container with node. but I can't connect app in container
Issue I am building container with node. I have two type of codes. I think two codes very simple and similar. and package.json and Dockerfile is same. just different code. but I can connect app in container. but the other
Continue readingDiscord bot is not running with uptime robot and repl.it
Issue I wanted to make my own discord bot wich should be online without my pc running, so i followed this tutorial: https://www.youtube.com/watch?v=Gqurhm2QxA0 It all worked fine and yesterday my bot was running and the whole time even without the
Continue readingGetting 'undefined' from asynchronous response despite 'await' and 'then'
Issue I’m trying to send a GET request, parse its response and return it to another method. Apparently I have problems handling the asynchronous response. I want to use Node.js’ standard modules, so no Axios. // class 1: Calling API,
Continue readingHow to insert/update `ARRAY` column in Postgres using Bookshelf/Knex
Issue I have a table in my Postgres database which contains a column with datatype ARRAY. I am using Bookshelf to perform operations on the database. Now, I want to insert/update (append new data to previous data in an array)
Continue readingmongoDB find from one collection and save in another collection
Issue I want to find a user from my user collection then inserting this exact user in another collection that have the same schema. Here is my implementation: (Controller) const user = await User.findOne({ _id: id }); if (user) {
Continue readingSublime Text 3: Build System – node.js. NPM module not executing
Issue I’m trying to execute node-dev in a sublime text 3 build system. node-dev is in my path: Yet when I run this build script: { “cmd”: [“node-dev”, “$file”], “selector”: “*.js” } I get this error, which also shows that
Continue readingNodejs Question about circular dependency
Issue I was testing circular dependency with commonjs. //index.js console.log(‘main starting’); const a = require(‘./a.js’); const b = require(‘./b.js’); console.log(‘in main, a.done = %j, b.done = %j’, a.done, b.done); //a.js console.log(‘a starting’); exports.done = false; const b = require(‘./b.js’); console.log(‘in
Continue readingNode.js: The registration token is not a valid FCM registration token
Issue I am developing a Flutter mobile app. From my Nodejs backend, I am trying to send FCM Notifications to the app. I downloaded the private key file from firebase console’s project settings. Below is my Nodejs code. const errorCodes
Continue readingNode.js: install only required modules of googleapis
Issue I am using NodeJs to send FCM notifications. Below is my code const errorCodes = require(‘source/error-codes’); const PropertiesReader = require(‘properties-reader’); const serviceAccount = require("service-account.json"); const fetch = require(‘node-fetch’); var { google } = require(‘googleapis’); var MESSAGING_SCOPE = ‘https://www.googleapis.com/auth/firebase.messaging’; var
Continue reading(nodemailer)Google disabled the less secure app option on google accounts i would like to find a way to send email with google .Or any other way
Issue I would like to find a way to send email from my app to the users either with some kind of google authentication or any other way… const nodemailer = require(‘nodemailer’) const sendEmail = async options => { const
Continue readingAccessing a div a button is wrapped in when button is pressed
Issue I’m currently designing a website that loads in a list of available items. I’m using EJS to dynamically load the items in from a database and displaying them in separate divs. However, I want the user to be able
Continue readingInternalOAuthError: failed to fetch user profile using express and passport js while implementing twitter strategy
Issue Hello this is my first project using Express and Passport, also my first oauth experience. I did successfully implement Google and Facebook strategies but the Twitter one is resisting since two days ago. It seems the Twitter strategy is
Continue readingHow to check UUID using regular expressions?
Issue In order to make validation over a api, i’m send companyId as UUID like: 71158c1a-56fd-4dd4-8e7f-fb95711a41de To have this validation I used jsonschema with the following patterns (test all 3 of them): /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$ /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi [\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12} jsonschema: companyId: { type: "string",
Continue reading"net::ERR_ABORTED 404" error in a NodeJS app running on Nginx
Issue I have an SPA facing this error and I cannot seem to figure out why I am receiving it. Bellow, my server.js // Load Node modules var express = require(‘express’); const bodyParser = require(‘body-parser’); const path = require(‘path’); const
Continue readingHow to run scripts in index.html in react if you don't have index.html
Issue I am still new to React. I have React web App to which I need to add several scripts. Although scripts have to be inside of body tag in index.html. Like this : <!DOCTYPE html> <html lang="en"> <head> <title>React
Continue readingNextJS: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined
Issue Using Nextjs and I’ve created an index.js in the /pages directory and created meta.js in the /components/meta/ directory. As my app rebuilds I get the following error: Element type is invalid: expected a string (for built-in components) or a
Continue readingHow to use parameters containing a slash character?
Issue My MongoDB keys in person collection are like this: TWITTER/12345678 GOOGLE/34567890 TWITTER/45678901 … I define getPersonByKey route this way: router.route(‘/getPersonByKey/:providerKey/:personKey’). get(function(req, res) { // get person by key var key = req.params.providerKey + ‘/’ + req.params.personKey; // … }
Continue readingExpress middleware runs for every imported .js file, is this normal?
Issue so I set up a basic express app that serves a static file from a directory named public. The public directory contains 3 files "index.html", "script1.js", "script2.js", and "script3.js". The script files are just empty .js files. index.html <!DOCTYPE
Continue readingDiscord.js not registering new slash commands because application names must be unique
Issue Discord.js won’t register my commands again, despite the fact they don’t exist. I’ve verified that the commands don’t exist by running: rest.get(Routes.applicationCommands(clientId)) .then(data => console.log(data)); with the only response being [] The error I get is this: DiscordAPIError[50035]: Invalid
Continue readingReturn items from text file as list in nodeJS
Issue Can someone tell me how to return items in a text file as a list. I’m writing code for basic authentication. It registers users then stores their information(first name, last name, gender, password) in a .txt file. I want
Continue readingInsert data on already existing User in mongodb
Issue Can anyone help me solve this problem, I’ve been stuck days on it and haven’t found any solution to. I have this user schema in my mongodb / node js: const userSchema = new Schema({ username:{ type: String, required:
Continue readingHow can I execute a bin with yarn?
Issue I have the following package.json and I’d like to run the bins "build" and "run": { "name": "simple-site", "version": "0.0.5", "license": "MIT", "bin": { "build": "./bin/build.js", "dev": "./bin/dev.js" } } I’ve tried: yarn run build and I get error
Continue readinghow to output console.log in url
Issue this fs = require(‘fs’); var data = fs.readFileSync(‘./number/data’, ‘utf8’); console.log(data) i can change to this await page.goto(‘https://web.whatsapp.com/send?phone=console.log(data);text=kaka’); Solution Do you want to output the contents of data into the URL? If yes then use string interpolation. await page.goto(`https://web.whatsapp.com/send?phone=${data};text=kaka`); Answered
Continue readingHow to handle a NoSuchKey error with aws-sdk in Node
Issue I can’t understand why my error handling isn’t catching the ‘NoSuchKey’ error from S3. It’s all within a try/catch, and there’s also error handling in the callback too. What am I missing? const s3 = new AWS.S3({ endpoint: new
Continue readingBind message supplies 1 parameters, but prepared statement "" requires 2
Issue I have a database goods with two columns id jsonb primary_key and name. Using this query: const query = ‘INSERT INTO “goods” (id, name) VALUES ($1, $2)’ together with the following data: const data = {id: 1, name: “milk”};
Continue readingDynamodb query with GSI and filter expression on non partition key and sort key columns in nodejs
Issue I have a GSI on my table and am using that GSI for querying results. Am using a filter expression as well const active_cases = await storesMonthlyAudit(); console.info("actives cases : ", active_cases) async function storesMonthlyAudit() { const params =
Continue readingTypeError: Cannot set properties of undefined (setting 'styles') + Using withLess/withSass/withCSS in next.config.js NextJS
Issue I am trying to configure a NextJS 12 project with custom Ant Design and according to some examples that I have found, I must configure my next.config.js file with the libraries @zeit/next-sass / @zeit/next-less / @zeit/next-css but when I
Continue readingIs there a way to request something from the backend and contiously search and refresh the database until it finds a match? then send the response
Issue I am struggling to make my own matchmaking in a multiplayer game of two players. I have a button that says "play",and i want if the user presses it to change in database his schema property "inQueue to true"
Continue readingHow do I use zlib in a react app? or what is zlib_binding and why is it missing?
Issue I have created a brand new react app using VS2022 and create-react-app. I have installed zlib using npm install zlib. getting the following error when running npm run start: ERROR in ./node_modules/zlib/lib/zlib.js 1:0-43 Module not found: Error: Can’t resolve
Continue readingedit column/attributes in sequelize migration
Issue Hi I’m new to migrations in sequelize, and I’m not sure how to add field/property for attributes. So my scenario is that I have two attributes sku & barcode, but I forgot to add unique: true. Now I need
Continue readingCannot read properties of undefined (reading '0') – ( empty error JSON response with postman)
Issue so i’m working with Joi for validation, and i’ve encountered this error when trying to post with postman. i’m follwing a tutorial, i tried to write it differently, but still have the same issue. i’m trying to access the
Continue readingHow to generate dynamic PDF invoices from a react APP and/or Express API
Issue I’m building a simple React app with an express/node API that allows users make orders for production. I need to find a way to generate dynamic PDF invoices based on the order data – similar to what a webshop
Continue readingReset password doesn't update my password in mongodb base
Issue I am first time making APIs about forgot password and then reset password. I am facing strange issue. There is not a single error, it gives me success status that password is updated. The problem is that in my
Continue readingNodeJS DES ECB encryption of hex data with module 'crypto'
Issue I am trying to encrypt/decrypt hex data using node js module ‘crypto’ with DES-ECB algorithm. In the official ‘crypto’ documentation, they give an example of aes-192 encryption in CBC mode (cf attached code) but with the ECB mode no
Continue readingUsing Firebase Auth with an external database
Issue I’m currently using Firebase to authenticate my users in a React/Node app, but I also want to store additional user data in my own database and I’m doing so by storing the Firebase uid on each user and I
Continue readingMissingSchemaError: Schema hasn't been registered for model "User, userSchema". Use mongoose.model(name, schema)
Issue hope you’re doing well. i’m following a tutorial ( from 2019 ), and i’m facing this error at the moment. here’s the code. ( let me know if you need anything else ) // index.js // const express =
Continue readingDiscord Bot | Ranking (Leaderboard?) System with discord.js and MongoDB
Issue I have a few questions to ask about a ranking (leaderboard…?) system in discord.js using MongoDB. I am following a tutorial made by CodeLyon for the setup of MongoDB, but afterwards I went ahead and created my own XP
Continue readingIs there any way to fix package-lock.json lockfileVersion so npm uses a specific format?
Issue If two different developers are using different versions of node (12/15) & npm (6/7) in a project that was originally created using a package-lock.json "lockfileVersion": 1, when the developer using npm 7x installs new packages it seems that the
Continue readingDocker + Node.js + Windows
Issue What I want: dockerize a Node.js web app (I am on Windows) Windows container docker-compose up gets me this error: Service ‘webapp’ failed to build: no matching manifest for windows/amd64 in the manifest list entries As far as I
Continue readingBufferizing data from stream in nodeJS for perfoming bulk insert
Issue How to bufferize efficiently in nodeJS on events from a stream to bulk insert instead of unique insert per record received from the stream. Here’s pseudo code I’ve got in mind: // Open MongoDB connection mystream.on(‘data’, (record) => {
Continue readingNot reading data and executing a function that does not exist
Issue So I’m building an API prototype and I have code that reads data from a Google Sheets (serving as a CMS) but the problem is when calling the route that I defined in Express.js it is not reading data
Continue readingHow can I broadcast to all clients with net module in node.js
Issue I can’t figure out how to do the equivalent of socket.broadcast.emit but using the net module of node.js instead of socket.io. I’m trying to connect a flash front end using flash built in socket libraries and node.js. I’m finding
Continue readingDisplay express.js res.send() without overwriting current html
Issue I am trying to create a calculator app using express.js to get request for an html file and a post request that takes the user’s input and responds with the answer. However, I want to display my answer inside
Continue readingHow to get node-sqlite3 working on Mac M1?
Issue I’m using Rosetta 2 with Homebrew and have sqlite3 installed. I added these to my ~/.zshrc so that the node compiler can find the brew installs: export PATH="/usr/local/opt/sqlite/bin:$PATH" export LDFLAGS="-L/usr/local/opt/sqlite/lib" export CPPFLAGS="-I/usr/local/opt/sqlite/include" I’m using installing using npm install sqlite3,
Continue readingreferenceerror: cannot access 'user' before initialization
Issue error showing: referenceerror: cannot access ‘user’ before initialization , I encored the password, after I called use, or there is an error will come like ***hashedPassword is not defiend *** so this why I call after bcrypt but that
Continue readingIn NodeJS, is res.sendStatus(status).send(message) Invalid?
Issue Whenever I return my HTTP response with : res.sendStatus(status).send(message) I get this error: Exception from a finished function: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client I couldn’t understand where I was sending a response
Continue readingAre there any engines to execute TypeScript code directly?
Issue When I first studied TypeScript, I found that node.js doesn’t execute TypeScript, so you need to install a TypeScript compiler that converts your TypeScript code into JavaScript. I searched until I found ts-node (TypeScript execution and REPL for node.js),
Continue readingNumber of reads for multiple Firebase trigger functions doing similar things
Issue I have an onUpdate firestore trigger function that does multiple things: functions.firestore.document(‘document’).onUpdate((change, context) => { const updatedObject = change.after.data() if (updatedObject.first) { doFirst() } if (updatedObject.second) { doSecond() } }) I am thinking of splitting this trigger into 2
Continue readingHow can I async await multiple synchronous MongoDB findOne functions with NodeJS
Issue I am using "await" on multiple MongoDB ".findOne" functions to different collections one at a time. I would like to let them all run synchronously together and somehow know when they are all ready to use. Instead of doing
Continue readingI can't figure out how to use Promise correctly in this context
Issue webhookClient.send(temp); executed earlier than temp[‘files’] = [link]; contains++; I need to wait for this. tg_bot.getFileLink – promise How to sync it correctly? let contains = 0 let temp = { username: `${msg.from.first_name} tg`, }; const user_profile = tg_bot.getUserProfilePhotos(msg.from.id); user_profile
Continue readingVUE-JSON-EXCEL Change format date
Issue I just want to ask on how to change format date for the VUE-JSON-EXCEL library? After i click the generate excel button, it will display in the excel a date format like this "2022-06-10T18:18:34.000Z" instead of "10/6/2022 18:18:34" Already
Continue readingHow to serve NodeJS application from IIS/Windows Server Edition OS without using iisnode?
Issue So, I’ve written a NodeJS application on Windows having Server Edition OS, My application basically communicates with other Softwares installed in the same system by executing some commands using NodeJS child process. Everything is working fine on localhost, as
Continue readingNo data returned from scraping rottentomatoes
Issue I cant figure out how to scrape the following data from https://www.rottentomatoes.com/browse/in-theaters/ Movie Title Review Score Release date Link to movie details Link to movie poster I’m not getting back any data or entering my each loop. Rotten Tomatoes
Continue readingIs this the correct way to do private functions in Javascript / node.js?
Issue A class I’m writing in node.js is as below: module.exports = exports = function(){ return new ClassA() }; function ClassA(){ this.myvariable = 0; } I have a function that I want to be private. To my understanding if the
Continue readingSuggest how to write this more compact
Issue Many equal properties names in this code. Is it possible to make it a lot compact ? constructor(product) { this.session = SessionBuilder.create(); this.id = product.id; this.name = product.name; this.root = product.root; this.pics = product.pics; this.sizes = product.sizes; this.colors =
Continue readingMongoose Model Custom Error Message for Enums
Issue I would like to customize the validation messages that my Mongoose Models produce. I tend to NOT put my validations (e.g. required) on the schema object directly because there is no freedom to have custom error messages. e.g. sourceAccountId:
Continue readingWhat's wrong with writing to a global variable In production mode?
Issue I looked at the sample code for connecting mongodb and saw a sentence that I did not understand. Why is it safe to use global variables in the case of development ? And why is not in production ?
Continue readingReferenceError: require is not defined using require("dotenv").config();
Issue For some reason i am having this error "ReferenceError: require is not defined" and i cant figure out why ?. Has anyone got an idea how i can fix this ? i am trying to connect my e-commerce website
Continue readingHow to create interconnected schemas in MongoDB with Mongoose?
Issue I am creating an web app for users to store their daily expenses. The app is in NodeJS and using Express. The schema for collecting users and users’ data is as follows: const dataSchema = new mongoose.Schema({ email:String, date:String,
Continue readingHow to fix "TypeError: props.scoreboard.map is not a function", only after refresh
Issue I’m having an odd issue when I’m trying to loop over my response from my backend. I’ve seen similar questions and they seem to point to the response not being an array, but logging my response does indeed result
Continue readinghow to retrieve image from s3 with nodejs
Issue Please let me know how to retrieve image from s3 with nodejs? Honestly, I could upload an image to s3 with nodejs as follows but the problem is how can I complete to retrieve image from s3? router.get(‘/image/:imageId’, function
Continue readingNode Axios POST is throwing 500 error on nested data object but works with a flat object
Issue I am making a very simple POST request with axios in an expressjs app like so: const try = async () => { const axios = require(‘axios’); const output = { url: "www.example.com"} await axios.post(`http://localhost:3000/myapp`, output) // do something
Continue readingMongoose: Find name similar to input
Issue I have an auto complete input box that I am working on and I am trying to make a mongoose endpoint that will get me user objects based on data from the input. The data can be incomplete, but
Continue readingCan't use ES modules in Google Cloud Functions
Issue I’m trying to deploy a very basic Google Cloud serverless application using Node.js, but it keeps showing the following error on Google Cloud Console: Provided module can’t be loaded. Is there a syntax error in your code? Detailed stack
Continue readingSnowflake session policy with idle timeout doesn't terminate sessions. Even with KEEP_ALIVE=false
Issue Context I am trying to reproduce the case where a session gets closed by inactivity. There is ‘manual’ way of doing it, which is to run SYSTEM$ABORT_SESSION(<session_id>), making your session no longer active. That’s ok, but I’m trying to
Continue readingNode.js create folder or use existing
Issue I already have read the documentation of Node.js and, unless if I missed something, it does not tell what the parameters contain in certain operations, in particular fs.mkdir(). As you can see in the documentation, it’s not very much.
Continue readingSequelize – How to search multiple columns?
Issue I have a database of articles with several columns and would like to be able to search both title and description. Currently, I have: Article.findAll({ where: { title: { like: ‘%’ + searchQuery + ‘%’ } } }); How
Continue readingsocket.io emits multiple times
Issue I have got a very basic example. This question has been asked previously multiple times in stack overflow itself but I could not get the right answer so I am going with this basic example. Server: var app =
Continue readingHow to create dto of an complex object in NestJs
Issue I’m a beginner at NestJs and I want to create a dto of the following struct: I want to create an API that can return this object using DTOs. export let Week = [ { DayName : "TuesDay", TimeZone:
Continue readingUnable to fill mongodb document with external api data
Issue I am trying to fill my mongodb document with data from unsplash and randomuser api. const userdata = await axios.get("https://randomuser.me/api/?results=51"); const imagedat = await axios.get( "https://api.unsplash.com/photos/random/?count=51&client_id=GWDzPpjHk743C2QnVBRxu8PtmOI3npF5sePZZ7o0pg4" ); I call both apis for 51 results but after 22 results the
Continue readingadjust console.log behaviour of custom object
Issue is there any way to influence what console.log gives out custom objects? I tried to overwrite the customObject.prototype.toString method, that did not work though. Any ideas? Solution In node.js, console.log calls util.inspect on each argument without a formatting placeholder.
Continue readingMongoose getting newly saved object id off by one
Issue I’m using the latest version of mongoose. var question = new CodingQuestion(reqJSON); question.save(function(err) { if (err) console.log(err); else{ var questionId = question.id; console.log(“successfully added question with id”, questionId); } }); The new object can be saved successfully. The problem
Continue readingredis v4 list sorted in reverse order
Issue I am trying to get a list in reverse score order. I am using node redis v4.0.1 which no longer supports client.ZREVRANGEBYSCORE If I try await client.zRangeByScoreWithScores(‘rankings’, ‘-inf’, ‘+inf’); This produces a list in ascending order. If I try
Continue readingMSBUILD : Configuration error MSB4148 "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0" has zero length
Issue I’m trying yo install electron-chromedrive by using yarn, so by doing this command: yarn add –dev electron-chromedriver –network-timeout 100000 But it gives the following error: MSBUILD : Configuration error MSB4148 "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0" has zero length Precisely: gyp ERR! build error
Continue readingnode-mysql – return rows where column contains string
Issue I want to create a function that returns objects from DB where a string is contained in one of the object’s columns. This is my code: router.get(‘/search-news’, function (req, res) { var input = req.query.title; // user input var
Continue readingpuppeteer not working on vps but running locally
Issue I wrote a little puppeteer program that let me log into twitter and check a few things. Locally on mac OS Catalina, it is working but on VPS ubuntu 18.04 lts not working. And shows me a log at
Continue readingImplement JS back-end and provide it an existing React front-end as an `/api` URI
Issue I’ve got an React app, which calls internally: /api/* actions. In my case these actions are satisfied by NginX which loads relevant back-end code and returns JSON response. I would like this React app to be "self-served", I would
Continue readingDifferences between express.Router and app.get?
Issue I’m starting with NodeJS and Express 4, and I’m a bit confused. I been reading the Express website, but can’t see when to use a route handler or when to use express.Router. As I could see, if I want
Continue readingPm2 stops my app after github action finishes
Issue I wrote a script deploy.sh to run as a step in the .github/deploy.yml file. This is the part in the yaml file where I execute the shell scipt – name: Execute script uses: appleboy/ssh-action@master with: host: ${{ secrets.HOST_DNS }}
Continue readingto be under different domain, why axios.post dont work
Issue https://github.com/skyturkish/e_commerce_advance this is the repo index.js const express = require(‘express’) const bodyParser = require(‘body-parser’) const UserService = require(‘./services/user-service’) const app = express() app.set(‘view engine’, ‘pug’) app.use(bodyParser.json()) app.get(‘/’, (req, res) => { res.render(‘index’) }) app.get(‘/users/all’, async (req, res) => {
Continue readingMongoose – Difference between Error.ValidationError, and Error.ValidatorError
Issue The question pretty much says it all. As far as I can tell from the docs, one is for general validation errors (a required field not being included, maxLength being exceeded, etc.). And one is given as the reason
Continue readingHow to auto run a code when user press Ctrl + C on cmd windows?
Issue Currently I am working with npm scripts, so when user runs npm start, it shows a list of logs and everything. Now as soon as user presses Ctrl+c to exit, I want to auto-run some command like clear to
Continue reading