GithubHelp home page GithubHelp logo

Comments (10)

diegohaz avatar diegohaz commented on May 26, 2024 1

Can you please do a fresh npm install and change body({ links }) to body({ links: [Object] })?

It should work now.

from bodymen.

tomexa avatar tomexa commented on May 26, 2024 1

I was blocked by this problem too and found my solution here :)
I had a mongo validation error because every field of my body that were objects were rendered as [object Object].
You should add the use case with the :[Object] in your Readme ;)

from bodymen.

diegohaz avatar diegohaz commented on May 26, 2024

Hi, @peteashworth

What is the value of links (the one you send as argument to body)?

I guess it's something like:

links: {
  type: String
}

If so, you need to change it to:

links: [{
  type: Object
}]

from bodymen.

peteashworth avatar peteashworth commented on May 26, 2024

Maybe I should dive deeper to understand the package, but here is what I have currently.

Mongoose Model

links: [{
    icon: String,
    url: String
  }]

Route

const { ... links } = schema.tree
...
router.put('/', body({links})

I tried the type: Object within the route body() which gave me [ '[object Object]' ]

from bodymen.

diegohaz avatar diegohaz commented on May 26, 2024

Oh, I can reproduce it. I'll investigate what is happening. Good catch.

from bodymen.

peteashworth avatar peteashworth commented on May 26, 2024

Cool; Thank you!

from bodymen.

peteashworth avatar peteashworth commented on May 26, 2024

Thanks for the quick fix. Doing as suggested, I can console log the links and its now showing correctly. Saving it into mongo is a different story (back to [object Object]) but willing to bet its with the _.merge().

Thanks again!

from bodymen.

peteashworth avatar peteashworth commented on May 26, 2024

all working. Thank you!

from bodymen.

diegohaz avatar diegohaz commented on May 26, 2024

Yay! 🎉

from bodymen.

tomgekeerd avatar tomgekeerd commented on May 26, 2024

Got this issue as well, but finally fixed it here. Would there be another solution to add required checks to the object parameters, maybe?

from bodymen.

Related Issues (9)

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.