node.js

yarn install consumes all memory on TeamCity and Jenkins

偶尔善良 提交于 2021-02-11 12:29:21
问题 I'd really like to get yarn working with TeamCity or Jenkins, however yarn install consumes all my build server's cpu & memory, even with a tiny npm project. Any idea why? Summary yarn install , when run by TeamCity or Jenkins, consumes most CPU/memory, never finishes running yarn install from the command line on the build server works (finishes in a few seconds) npm install completes in a few seconds when run by TeamCity/Jenkins build server: Windows Server 2012, 2 cores, 4GB mem yarn

compoent interaction with rxjs in angular

陌路散爱 提交于 2021-02-11 12:29:12
问题 i make news application with news api and i fetch data properly and but not sending data from service to component so how can send data from service to component and component to component through rxjs import { Injectable } from '@angular/core'; import { Subject } from 'rxjs'; @Injectable() export class NewService { private pushSource = new Subject<object>(); Country_Name; constructor(private http:HttpClient,) { this.messages$ = this.pushSource.asObservable() } // define function for call the

fetching data from API in react poll

可紊 提交于 2021-02-11 12:28:07
问题 I want to fetch data from API and show frontend using react but I am getting error from frontend side which is (TypeError: answers.map is not a function ) so how can I solve this error -- MY CODE IS - import React, { useState, useEffect } from "react"; import Poll from "react-polls"; import { getPolls } from "../helper/coreapicalls"; const MainPoll = () => { const [polls, setPoll] = useState([]); const [error, seterror] = useState(false); // Setting answers to state to reload the component

Using async/await with a forEach loop

假装没事ソ 提交于 2021-02-11 12:24:29
问题 Are there any issues with using async / await in a forEach loop? I'm trying to loop through an array of files and await on the contents of each file. import fs from 'fs-promise' async function printFiles () { const files = await getFilePaths() // Assume this works fine files.forEach(async (file) => { const contents = await fs.readFile(file, 'utf8') console.log(contents) }) } printFiles() This code does work, but could something go wrong with this? I had someone tell me that you're not

Regex for TODO keyword when passing through a list of directories to get a list of files with TODO keyword (eg. //TODO) but not as variable / string

自作多情 提交于 2021-02-11 12:24:21
问题 I'm trying to write an application that looks through a directory and flag out all files (be it in directory or subdirectories) that has the TODO keyword (the one that flashes/highlights in color whenever we code in our code editor [i am using visual studio code] I have gotten most of the code running, its just the last bit that is puzzling me : because my RegEx accepts 'TODO' as a word block, it picks up even files that has TODO as variable name / string content eg. var todo = 'TODO' or var

simple typescript function with axios get call does not work

强颜欢笑 提交于 2021-02-11 12:23:28
问题 I am learning to do http calls from node/typescript application. I have the following method, using npm package Axios to do a http get call to a fake api end point. public GetTrailById(trailId: number) : string { console.log("Entered the method."); const res = axios.get("https://reqres.in/api/users?page=2") .then((res: { data: any; }) => { console.log("inside then"); return "this is good, got response"; }) .catch((err: { response: any; }) => { console.log("inside catch"); return "this is not

Firebase Functions throw function with internal error [closed]

橙三吉。 提交于 2021-02-11 12:22:37
问题 Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 months ago . Improve this question I am developing a project under Firebase Hosting with Firebase Functions. Index.js: exports.simpleFunction = functions.https.onCall((data, context) => { return data; }); Index.html: var simpleFunction = firebase.functions().httpsCallable('simpleFunction'); simpleFunction("12")

How to Post “multipart/form-data” Form and get the Text field values from the Node.js server?

孤者浪人 提交于 2021-02-11 12:22:06
问题 Í'm trying to upload a file using multer. I can upload the file but somehow unable to get the text box values inside the form with the content/type "multipart/form-data". <div class="container"> <h1>File Upload</h1> <form action="/upload" method="POST" enctype="multipart/form-data" > <div class="file-field input-field"> <div class="btn grey"> <span>File</span> <input name="myImage" type="file" multiple="multiple"> </div> <div class="file-path-wrapper"> <input class="file-path validate" type=

req.session.userId returns undefined in post request

倾然丶 夕夏残阳落幕 提交于 2021-02-11 12:20:21
问题 I have the line req.session.userId = user._id; in a post request with route /signin . When I put console.log(req.session.userId) after that line, it does return the user id. But req.session.userId returns undefined in a post request with route /notes . How can I get the user id? session in MongoDB Compass indeed contains the userId: {"cookie":{"originalMaxAge":null,"expires":null,"httpOnly":true,"path":"/"},"userId":"5b1634522951cc240c2fe55f"} client post request /notes fetch('http:/

moment.js: Deprecation warning: value provided is not in a recognized RFC2822 or ISO format [duplicate]

浪尽此生 提交于 2021-02-11 12:16:55
问题 This question already has answers here : Deprecation warning in Moment.js - Not in a recognized ISO format (9 answers) Closed 1 year ago . I am getting date as input from an external source and it is a string, const a = '08-01-2019'; And required format for me is 'MM-DD-YYYY', const outputDateFormat = 'MM-DD-YYYY'; And I am using moment.js and doing below manipulations on that date like adding a year and decreasing a day, //adding a year const a = moment(a).add(1, 'years').add(-1, 'days')