Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

controller : app.get(/update, (req, res) => { console.log(req.query); users.replaceUser(req.query._id, req.query.name, req.query.age, req.query.email, req.query.phoneNumber) .then(updateCount => { console.log(updateCount); res.send({ updateCount: updateCount }); }) .catch(error => {

controller :

app.get(\"/update\", (req, res) => {

console.log(req.query);

users.replaceUser(req.query._id, req.query.name, req.query.age, req.query.email, req.query.phoneNumber)

.then(updateCount => {

console.log(updateCount);

res.send({ updateCount: updateCount });

})

.catch(error => {

console.error(error);

res.send({ error: 'Request failed' });

});

});

model:

const replaceUser = async (_id, req) => {

const result = await User.findOneAndUpdate({ _id: req.query._id}, req.query);

return result.nModified;

I am unfamiliar with JavaScript and cannot get this to work: I keep getting this error TypeError: Cannot read property 'query' of undefined

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Usability

Authors: Jakob Nielsen, Raluca Budiu

1st Edition

0133122131, 9780133122138

More Books

Students also viewed these Programming questions

Question

Draw a schematic diagram of I.C. engines and name the parts.

Answered: 1 week ago

Question

Does log 81 (2401) = log 3 (7)? Verify the claim algebraically.

Answered: 1 week ago