Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Mongoose READ

// Get all users
app.get('/users', (req, res) => {
  Users.find()
    .then((users) => {
      res.status(201).json(users);
    })
    .catch((err) => {
      console.error(err);
      res.status(500).send('Error: ' + err);
    });
});
Comment

Mongoose READ

app.get('/students', (req, res) => {
  Students.find().then(users => res.json(users));
});
Comment

Mongoose READ

// Get a user by username
app.get('/users/:Username', (req, res) => {
  Users.findOne({ Username: req.params.Username })
    .then((user) => {
      res.json(user);
    })
    .catch((err) => {
      console.error(err);
      res.status(500).send('Error: ' + err);
    });
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: react google map api 
Javascript :: find all even numbers javascript 
Javascript :: react get current date minus 7 days 
Javascript :: krakend config example 
Javascript :: js try..catch works synchronously. 
Javascript :: pop javascript 
Javascript :: find option values using javascript 
Javascript :: export csv single javascript 
Javascript :: update node two versions mac 
Javascript :: array of objects in javascript short 
Javascript :: extends in js 
Javascript :: discord.js v12 how to set owner commands 
Javascript :: what is prototype javascript 
Javascript :: get file extension of path extendscript 
Javascript :: javascript set value to the largest value in an array 
Javascript :: a function that returns a string javascript 
Javascript :: /learn ES6: Use the Spread Operator to Evaluate Arrays In-Place 
Javascript :: how to filter items in react state 
Javascript :: abstract class in js 
Javascript :: unexpected token w in json at position 0 
Javascript :: gravity form on submit jquery 
Javascript :: read files in javascript 
Javascript :: Object Property Shorthand javascript 
Javascript :: react useeffect hooks 
Javascript :: best way to setup nextjs project 
Javascript :: sorting an array based on certain element 
Javascript :: conditional operator 
Javascript :: momoent isafter or equal$ 
Javascript :: how to use promise.all 
Javascript :: vue method 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =