Skip to content
Advertisement

Tag: express

try/catch block not working on express js

I try to create one route using express.js with a try/catch block, but when the conditions in the try block are not met, the code just loads without returning any value any solution for this problem? Answer You are not responding anything to the client in case name !== ‘name’ Add an else with a response, or throw an exception

JS fetch should do action on server write

Given is the following node stack: Client (VUE) (8080) Server (express.js) (3000) The client sends a get to a server route, inside the server route a task is running that takes some time but could easily been mapped because server is working over an array of data. Is it possible that the server can send a response (write?) which triggers

MongoDb query return empty object

I’m trying to perform a simple .find() query on my mongodbAtlas, but the result of this query is an empty object. this is my server file: this is my routes file: this is how my document is populated: Answer I think you are missing the “await” keyword after const data….. as API data fetching calls are asynchronous and required promise/

I am trying to fetch information from phpmyadmin database, but in browser it’s showing cannot get/employee and in command prompt there is no error

Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. Try the new cross-platform PowerShell https://aka.ms/pscore6 PS E:Developmentcrud-node> node index.js Express server is running on port number: 8000 DB connection is successful Answer there seems to be spelling mistake in end point. The one you specified in error detail and the one defined in the code are different

How to export and use a function using Express?

I have two file alarm.js and notifications.js. In alarm.js I need to call a method called sendPush from notifications.js. What I’ve tried : Exporting the function from notifications.js: Importing it in alarm.js and use it : The problem: I keep getting the error saying helperNotif.sendPush is not a function The question : How can I call this notification.js sendPush function

Advertisement