I am new to Javascript, I want to initialize my object in the following way { ‘101’ : { Name: ‘A’, Add: ‘123’ }, ‘115’ : { Name: ‘B’, Add: ‘456’ } } and so on, I am going to execute this in a loop, the key(101,115..) is unique and value should be an object. ..
Category : node.js
I know, that there is already few threads about this, but I am very courious what is more correct in this example: // This is not correct and showing "’throw’ of exception caught locally" warning function test1(input: any): boolean { try { if (!input) throw new Error("You not set test variable."); const number: int = ..
In my chatroom, there is a settings menu, you can check on and off, 2 settings. I want a user to check or uncheck it and save the state that the checkmark is in after refresh. I have been researching for a while and nothing is working. I’m not really sure where to start so ..
I’m using Sequelize as my main ORM, sequelize client is creating in /models/index.js file of a project and uses environmental variables from .env file: import { Sequelize } from ‘sequelize’; const { DATABASE_DIALECT, DATABASE_HOST, DATABASE_PORT, DATABASE_USER_NAME, DATABASE_USER_PASSWORD, DATABASE_NAME } = process.env; console.log("MODEL LOADING") const sequelize = new Sequelize(DATABASE_NAME as string, DATABASE_USER_NAME as string, DATABASE_USER_PASSWORD as ..
I am trying to get mongoose return data from local MongoDB instance. Eveything else is running fine. The form is giving data to passport. I have also inserted data into mongodb manually. The only error is in user.findOne. When I print user into console, instead of returning some data it returns null const passport = ..
I have a little problem here, using the POST REQUEST and sending data is fine I guess I can see that an ID is created but no description whatsoever, this only occurs on the table called route_id, the one called lists_id works fine. I am a rookie so i have obviously made a mistake somewhere ..
I am stuck with this complex scenario, I would really appreciate the help. Example data: This is could be ANYTHING, its a text area where user can type EITHER objects or strings let body = { docs: [{ id: 1, text: ‘#hash’ }], orEven: ‘$.text’, orThis: { random: ‘$.language’, }, }; Goal (2 things) For ..
The following code didn’t generate desired results: import axios from ‘axios’ import qs from ‘qs’ var data = qs.stringify({ ‘account’: ‘xxxxxxxx’, ‘pwd’: ‘xxxxxxx’, }); var config = { method: ‘post’, url: ‘http://example.com/doLogin’, headers: { "Content-Type": "application/x-www-form-urlencoded", }, withCredentials: true, data: data }; axios(config).then(function (response) { console.log(response); }) I printed out axios response json and noticed ..
I cannot figure to add a new field with multiple conditions in MongoDB. Here is how DB looks like, const db = [ { _id: 1, isActived: false, // Drafted isScheduled: false, isExpired: false }, { _id: 2, isActived: true, isScheduled: true, // Scheduled isExpired: false }, { _id: 3, isActived: true, // Expired isScheduled: ..
I am struggling with an API-call, since my response object is always undefined. Every console.log(res) returns undefined. This wouldn’t be a problem, but I need to call res.json() to send to front-end. Unfortunately, I can’t call send() on an undefined object. Here is my API call, I added some comments to explain. router.route("/run").post((req: any, res: ..
Recent Comments