Where should { useNewUrlParser: true } be placed in my configuration?

I'm having trouble determining the correct placement for { useNewUrlParser: true}. Should I adjust how I connect to Mongo?

var express = require('express');
var router = express.Router();
var assert = require('assert');


var url = 'mongodb://urlformyconnection;
const MongoClient = require('mongodb').MongoClient;
const objectId = require('mongodb').ObjectID;
const client = new MongoClient(url);
const dbName ='transactions';
.....
router.post('/insert', function (req, res, next){

  var item = {
    firstN: req.body.firstN,
    lastN: req.body.lastN,
    ccNum: req.body.ccNum,
    cvc: req.body.cvc,
    zip: req.body.zip,
    amount: num
  };

  MongoClient.connect(url, function(err, client)
  {assert.equal(null, err);
    const db = client.db(dbName);
    db.collection('transac-info').insertOne(item, function (err, result) {
      assert.equal(null, err);
      console.log('Transaction Inserted');
      client.close();
    });
  });

  res.redirect('/');
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The blast.js example runs flawlessly on CodePen but encounters issues when run locally

I recently discovered blast.js and am encountering a problem when trying to run an example. The example functions perfectly on codepen, but fails to work on my local machine. The console is showing the following warning and error message. Any assistance fr ...

Arranging xCharts based on the weekday order

Struggling with xCharts, specifically trying to display a bar chart showing numbers with corresponding days of the week in order. Despite my efforts, I can't seem to get them to appear in the correct sequence. Refer to the image below for reference: ...

Is there a way to use jQuery to toggle a child element when the parent is clicked?

There are three images displayed on a webpage, each accompanied by a list of three events. The desired functionality is that when a user clicks on an event, the corresponding information should be displayed below that event. Below is the HTML structure: & ...

What are the steps to retrieve marker data from a MySQL database and showcase them dynamically on a Google Map using AJAX? Addressing time constraints

Utilizing a combination of JavaScript, Google Maps API, PHP, and MySQL, my app is designed to extract a list of markers from a MySQL database, export them to a myXML.xml file, and then load these markers onto the map each time it loads. <!DOCTYPE html& ...

Log out of Google+ API results in an error message stating: '$apply already in progress'

After successfully implementing the signIn functionality using Google+ API in my AngularJS web app, I encountered some issues with getting the signOut functionality to work properly. Within one of my .html files (the Nav-bar), I have a function being call ...

Issue with react-addons-css-transition-group and multiline TextFields in Material-UI TextField

If a TextField with multiline is nested inside a react-addons-css-transition-group, it seems to disrupt the show transition. Any suggestions on how to handle this situation effectively? Check out my code snippet here: https://codesandbox.io/s/material-dem ...

Is the VueJs and ChartJs combination causing the chart to be width-responsive, but not height-responsive?

I've exhausted all options, but I can't seem to make the height of my chart respond effectively. The width is behaving as expected, adjusting responsively, but the height stubbornly remains fixed at 400px. Within my primary Vue application, I i ...

Creating a dynamic key for an object in node js using javascript

Currently, I'm trying to achieve the following: let obj = {} obj.obj1 = {'obj11':5} console.log(obj.obj1.obj11) //5 However, my aim is to dynamically define the last key of the last object. For instance, attempting something like this: ...

The custom error handling middleware in Express.js appears to be ineffective for certain error cases

The custom error handler code snippet provided below: export const errorHandler: ErrorRequestHandler = (err, _, res) => { if (err instanceof HttpError) { res.status(err.statusCode).json({ message: err.message }); return; } res.st ...

The data from the Flickr API is consistently unchanging

I created a simple weather app that retrieves weather data using a "POST" request and displays it successfully. Users have the ability to search for weather by city, and I wanted to enhance the app by loading an image of that city through a separate jQuer ...

What is the best way to randomly display an image from a JavaScript array within an HTML document?

I currently have this code in my HTML and JavaScript files, but I am having trouble with displaying images without using a URL in the JavaScript file. The images are located in my project folder. However, when I open the HTML file, the images do not appear ...

"Unsettled" JavaScript variable persists during Ajax page transition

I'm currently working on a CRUD app using php/js, where an ajax page change is essential. Within the "add view," there is a basic table and a button that adds a new row whenever you click on it. Initially, on the first load, clicking the button adds ...

I have a parent DIV with a child DIV, and I am looking to use jQuery to select the last child DIV. The parent DIV has an

In my HTML code, I have a parent div called "allcomments_4" which contains several child divs with unique IDs (oneEntry), each with their own children. My goal is to locate and retrieve the content inside the last child of the parent node (lastComment) and ...

Function for editing a button in an AngularJS single page application

I am a beginner in AngularJS and I'm currently working on a project to create a single page application for tracking expenses. However, I'm facing some challenges with my code. Although I have successfully implemented most of the functions, I am ...

refresh the div post AJAX call

Does anyone know how to refresh or reload a div after making an ajax request? Here is the code I currently have: function Register(event) { event.preventDefault(); console.log(event); $.ajax({ type: 'POST', url: regis ...

Alert: Jade has detected an unforeseen block called "scripts"

I created a jade file with the following content: extends layout block content h1= title p Hello and welcome to #{title} block scripts script(src='/socket.io/socket.io.js') script(src='/javascripts/client.js') But when I try ...

Troubleshooting encoding problems when storing HTML in Mongodb

As I develop a web crawler, my next step is to store the extracted html into my MongoDB database. Here's what I have so far(using pymongo): c=urllib2.urlopen(myUrl) html=c.read() db.urls.insert( { ...

Create a connection between a div and a React component, allowing for the seamless transfer of

I'm looking to implement a feature where clicking on a specific div will redirect the user to another page, similar to React Router. However, I currently lack the knowledge to make it happen. Below is the code snippet in question: const Card: React.FC ...

Is there a way for me to have a table automatically scrolled to a specific column upon loading the HTML page?

My table contains a dynamic number of columns based on the months inputted from the database starting from a start_date and ending at an end_date. I have the current_date stored as a variable and want the table to load with the x-scrollbar positioned right ...

Toggle the selections of items from different lists when any item is selected, excluding the current selection

I am currently facing an issue with using two selectable lists that have the same selectable class. My goal is to toggle all items regardless of their parent list when a selection is made. However, at the moment, when I select an item, only the selections ...