Giter Club home page Giter Club logo

Comments (4)

peweet avatar peweet commented on June 22, 2024

Having this exact issue did you ever manage to fix it?

from mean-machine-code.

sahibjotsaggu avatar sahibjotsaggu commented on June 22, 2024

@mikevarela @peweet Do you guys get any error messages? If so, what are they?

from mean-machine-code.

fe98 avatar fe98 commented on June 22, 2024

Here's the error I'm getting. Guessing this is what they're getting as well...

API Requested
(node:535) DeprecationWarning: Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/promises.html
{ ValidationError: User validation failed: password: Path `password` is required., username: Path `username` is required.
    at ValidationError.inspect (/mnt/c/Web/mean-machine/node_modules/mongoose/lib/error/validation.js:57:23)
    at formatValue (util.js:362:36)
    at inspect (util.js:226:10)
    at format (util.js:98:24)
    at Console.log (console.js:113:24)
    at /mnt/c/Web/mean-machine/server.js:54:19
    at /mnt/c/Web/mean-machine/node_modules/mongoose/lib/model.js:3822:16
    at /mnt/c/Web/mean-machine/node_modules/mongoose/lib/services/model/applyHooks.js:167:17
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)
  errors:
   { password:
      { ValidatorError: Path `password` is required.
          at ValidatorError (/mnt/c/Web/mean-machine/node_modules/mongoose/lib/error/validator.js:25:11)
          at validate (/mnt/c/Web/mean-machine/node_modules/mongoose/lib/schematype.js:758:13)
          at /mnt/c/Web/mean-machine/node_modules/mongoose/lib/schematype.js:805:11
          at Array.forEach (<anonymous>)
          at SchemaString.SchemaType.doValidate (/mnt/c/Web/mean-machine/node_modules/mongoose/lib/schematype.js:765:19)
          at /mnt/c/Web/mean-machine/node_modules/mongoose/lib/document.js:1481:9
          at _combinedTickCallback (internal/process/next_tick.js:131:7)
          at process._tickCallback (internal/process/next_tick.js:180:9)
        message: 'Path `password` is required.',
        name: 'ValidatorError',
        properties: [Object],
        kind: 'required',
        path: 'password',
        value: undefined,
        reason: undefined,
        '$isValidatorError': true },
     username:
      { ValidatorError: Path `username` is required.
          at ValidatorError (/mnt/c/Web/mean-machine/node_modules/mongoose/lib/error/validator.js:25:11)
          at validate (/mnt/c/Web/mean-machine/node_modules/mongoose/lib/schematype.js:758:13)
          at /mnt/c/Web/mean-machine/node_modules/mongoose/lib/schematype.js:805:11
          at Array.forEach (<anonymous>)
          at SchemaString.SchemaType.doValidate (/mnt/c/Web/mean-machine/node_modules/mongoose/lib/schematype.js:765:19)
          at /mnt/c/Web/mean-machine/node_modules/mongoose/lib/document.js:1481:9
          at _combinedTickCallback (internal/process/next_tick.js:131:7)
          at process._tickCallback (internal/process/next_tick.js:180:9)
        message: 'Path `username` is required.',
        name: 'ValidatorError',
        properties: [Object],
        kind: 'required',
        path: 'username',
        value: undefined,
        reason: undefined,
        '$isValidatorError': true } },
  _message: 'User validation failed',
  name: 'ValidationError' }
POST /api/users?name=test&username=testusername&password=testpassword 200 78.294 ms - 646

from mean-machine-code.

peweet avatar peweet commented on June 22, 2024

I forget if I managed to fix but this is what I think I did. If you read the error carefully it tells you exactly whats wrong.
'username' & 'password' values are needed.
The code is executing perfectly but fails as actual values are needed.

So quite simply the validation has failed because the computer is too stupid to figure out what to do when it has nothing to work with! :-)

We need to pass in a generic password and user to fill the undefined value. Or write a usecase to handle the null value.

ie a bit of psuedo

IF empty PRINT 'Sorry buddy you have to type something for me to work ENDIF

So find a way to pass user and password values through the command line to see it works at runtime. If that doesn't work manually try put in values directly into the Javascript.

var user = new User(); // create a new instance of the User model user.name = req.body.'Elvis Presley'; // set the users name (comes from the request) user.username = req.body.'ElvisPresley123'; // set the users username (comes from the request) user.password = req.body.'VivaLasVegas'; // set the users password (comes from the request)

from mean-machine-code.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.