Question

Q3 Which of the following Node.JS express router methods is the correct way to access the...

Q3
Which of the following Node.JS express router methods is the correct way to access the value of the 'name' key for the object in question 2.

router.get('/person.json', function(req, res) {

    var name  = JSON.parse(res.body).name;
    
    // Do stuff
    res.send('');
    
});
router.post('/person.json', function(req, res) {

    var name  = req.body.name;
    
    // Do stuff
    res.send('');
    
});
router.post('/person.json', function(req, res) {

    var name  = JSON.parse(req.body).name;
    
    // Do stuff
    res.send('');
    
});
router.post('/person.json', function(req, res) {

    var name  = res.body.name;
    
    // Do stuff
    res.send('');
    
});

Q4
Which of the following statements about Cookies are true?

Cookies are a safe way to store sensitive site information.

Cookies are useful for storing information short-term.

Cookies are useful for storing information long-term.

Cookies allow the client to store state information on the server

Cookies allow the server to store state information on the client

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Q3:

Ans:

Option (a) is incorrect because we are parsing the object from the "res" variable using: var name =JSON.parse(res.body).name; but we will get the JSON object in the "req" variable.

Option (b) is incorrect because we are not even parsing the response object and directly using: var name = req.body.name; but , we will get the required value by parsing the object inside the "req" variable using JSON.parse()

Option (c) is correct because we are getting the object from the correct variable i.e, the "req" variable and also parsing the object to get the value of the "name" key.

Option (d) is incorrect because it is nether using the correct correct variable "req" nor it is parsing the variable.

(Thank You !!, Please consider upvoting if it was helpful !!)

Add a comment
Know the answer?
Add Answer to:
Q3 Which of the following Node.JS express router methods is the correct way to access the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • // Write the compiler used: Visual studio // READ BEFORE YOU START: // You are given...

    // Write the compiler used: Visual studio // READ BEFORE YOU START: // You are given a partially completed program that creates a list of patients, like patients' record. // Each record has this information: patient's name, doctor's name, critical level of patient, room number. // The struct 'patientRecord' holds information of one patient. Critical level is enum type. // An array of structs called 'list' is made to hold the list of patients. // To begin, you should trace...

  • Hello! I'm posting this program that is partially completed if someone can help me out, I...

    Hello! I'm posting this program that is partially completed if someone can help me out, I will give you a good rating! Thanks, // You are given a partially completed program that creates a list of employees, like employees' record. // Each record has this information: employee's name, supervisors's name, department of the employee, room number. // The struct 'employeeRecord' holds information of one employee. Department is enum type. // An array of structs called 'list' is made to hold...

  • Will facebook be able to have a successful business model without invading privacy? explain your answer?...

    Will facebook be able to have a successful business model without invading privacy? explain your answer? could facebook take any measures to make this possible? BUSINESS PROBLEM-SOLVING CASE Facebook Privacy: Your Life for Sale Facebook has quickly morphed from a small, niche haps most obviously. Facebook allows you to keep in networking site for mostly Ivy League college stu- touch with your friends, relatives, local restaurants, dents into a publicly traded company with a market and, in short, just about...

  • I have this case study to solve. i want to ask which type of case study...

    I have this case study to solve. i want to ask which type of case study in this like problem, evaluation or decision? if its decision then what are the criterias and all? Stardust Petroleum Sendirian Berhad: how to inculcate the pro-active safety culture? Farzana Quoquab, Nomahaza Mahadi, Taram Satiraksa Wan Abdullah and Jihad Mohammad Coming together is a beginning; keeping together is progress; working together is success. - Henry Ford The beginning Stardust was established in 2013 as a...

  • 10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated...

    10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated sludge operation that adversely affect effluent quality with origins in the engineering, hydraulic and microbiological components of the process. The real "heart" of the activated sludge system is the development and maintenance of a mixed microbial culture (activated sludge) that treats wastewater and which can be managed. One definition of a wastewater treatment plant operator is a "bug farmer", one who controls the aeration...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT