I have don’t the API check if the token is expired. I have to make a GET call, if I got the 403, error from the API, then I should re-login. I attempted. app.get = async (body) => { return new Promise((resolve, reject) => { let user = await user.findOne({ where: { accountId: body.accountId } ..
Category : express
Everyone use this code, but this is valid to use in production?, and what is the consequences of console.log in general in production code in node? app.listen(PORT, () => console.log(`server is running on port ${PORT}`)); Source: Ask Javascript..
I am trying to pass a simple json to the server using POST. How do I retrieve the value on the server side? In this case, the value is a stringified JSON [{"key": "value"}], which accounts for the [0] on the server. index.html <form id="form" method="POST" style="background-color:#92a8d1" style="font-size: 18px; font-family:verdana,arial,tahoma,serif;"> <label for="data">Demonstrations:</label><br> <ul> <li><input type="button" ..
I am trying to: a) Create an order from my current cart b) Populate the response of the order with the selected object attributes in the "select" c) Finally, I would like to delete the cart. I have tried the below but here are my problems: the result response does not come back populated even ..

The problem I have a Node application running in ECS that seems to be leaking memory, as the memory is constantly growing and dropping at every deploy. I made a heapdump and imported it in Chrome DevTools, trying to make some sense of it. Heapdump There seems to be several 100 000 strings looking like ..
I am learning the mean stack and I have a file I generate on the server-side of my application I intend to download this file from my angular front end when a button is clicked. but when I click the button nothing happens, I check my back end the file is generated successfully and everything ..
so i started learning backend recently, with node/expres. Im building a small REST API for learning purposes, with the following routes: GET /api/products >> to display a list of products GET /api/cart >> to display list of items inside the cart DELETE /api/cart/:id >> to delete an item from the cart now, i want to ..
Good day am trying to create a form that registers a user into the system by only using a login form. Creating a user ,matching passwords is working but at the first if statement where it checks if the fields are not empty the application breaks and it gives an error: "events.js:292 throw er; // ..
I have a function in the middleware file called setSignedInUser which receives a cookie as a parameter. I want to find a user saved in the SignedIn collection with the cookie,retrieve the user’s unique id ,search for the user’s complete information from the Users collection and return the foundUser which I would like to access ..
//jshint esversion:6 const express = require("express"); const bodyParser = require("body-parser"); const mongoose = require("mongoose"); const _ = require("lodash"); const app = express(); app.set(‘view engine’, ‘ejs’); app.use(bodyParser.urlencoded({ extended: true })); app.use(express.static("public")); mongoose.connect(‘mongodb+srv://admin-sonu:[email protected]/todolistDB’, { useNewUrlParser: true, useUnifiedTopology: true }); const workItems = []; const itemsSchema = new mongoose.Schema({ name: String }); const Item = mongoose.model("Item", itemsSchema); const ..
Recent Comments