Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module.exports = {
- //List all users registered in Upics
- async ListAllUsers(req, res) {
- try {
- //Query to users collections
- const pruebas = [];
- const ListUsers = await users.find();
- pruebas.push(ListUsers);
- //detect if exist info
- if (pruebas.length == "") {
- return res.serverError({
- err: "Users not found"
- });
- } else {
- //load all users
- for (let i=0; i <= pruebas.length -1 ; i++) {
- //empty array
- const info = [];
- for (let j = 0; j <= pruebas[i].length - 1; j++) {
- info.push({
- username:pruebas[""]
- });
- }
- console.log(info);
- }
- }
- } catch (err) {
- if (err.name === "ValidateError") {
- return res.badRequest({err: 'Not found users!'});
- } else {
- return res.serverError({err:"Error, try again!"});
- }
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement